<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Últimas mensagens do tópico "Pegar um list do banco"]]></title>
		<link>http://www.guj.com.br/posts/list/24.java</link>
		<description><![CDATA[Últimas mensagens enviadas no tópico "Pegar um list do banco"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Pegar um list do banco</title>
				<description><![CDATA[ Galera,<br /> <br /> Sou novato em Flex.<br /> <br /> Estou querendo pegar uma lista do banco e colocar em grid no flex. Estou usando o BlazeDS.<br /> <br /> Abaixo segue o meu codigo.<br /> <br /> Nao sei onde estou errando. Tem alguma maneira mais facil de fazer sem ser essa que estou tentando fazer?<br /> <br /> Outra coisa, nao esta lancando nenhum erro, simplesmente nao funciona.<br /> <br /> Classe cliente.java<br /> <br /> [code]<br /> package br.com.ces.sgmv.entity;<br /> <br /> public class Cliente {<br /> 	private String nome;<br /> <br /> 	public String getNome() {<br /> 		return nome;<br /> 	}<br /> <br /> 	public void setNome(String nome) {<br /> 		this.nome = nome;<br /> 	}<br /> }<br /> <br /> [/code]<br /> <br /> Meu Service, aqui estou simulando como se estivesse pegando do bando de dados.<br /> <br /> [code]<br /> import java.util.ArrayList;<br /> import java.util.List;<br /> <br /> import br.com.ces.sgmv.entity.Cliente;<br /> <br /> public class ClienteService {<br /> 	<br /> 	public List&lt;Cliente&gt; buscarTodosCliente(){<br /> 		List&lt;Cliente&gt; list = new ArrayList&lt;Cliente&gt;();<br /> 		try {<br /> 			<br /> 			for(int i = 0; i &lt; 20; i++){<br /> 				Cliente cliente = new Cliente();<br /> 				cliente.setNome("cliente" + i);<br /> 				list.add(cliente);<br /> 			}<br /> 		} catch (Exception e) {<br /> 			e.printStackTrace();<br /> 		}<br /> 		return list;<br /> 	}<br /> }<br /> [/code]<br /> <br /> Meu ActionScript relacionado a classe cliente em java<br /> <br /> [code]<br /> package br.com.ces.sgmv.flex.dto.modelo<br /> {<br /> 	[RemoteClass(alias="br.com.ces.sgmv.entity.Cliente")]<br /> 	public class Cliente<br /> 	{<br /> 		public var nome:String;<br /> 	}<br /> }<br /> [/code]<br /> <br /> O trecho que estou usando no meu remoteconfig<br /> <br /> [code]<br /> &lt;destination id="clienteService"&gt;<br /> 		&lt;properties&gt;<br /> 			&lt;source&gt;br.com.ces.sgmv.service.ClienteService&lt;/source&gt;<br /> 		&lt;/properties&gt;<br /> 	&lt;/destination&gt;<br /> [/code]<br /> <br /> e por fim o meu mxml<br /> <br /> [code]<br /> &lt;?xml version="1.0" encoding="utf-8"?&gt;<br /> &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" <br /> 	xmlns:dto="br.com.ces.sgmv.flex.dto.modelo.*"<br /> 	layout="absolute"&gt;<br /> 	<br /> <br /> &lt;mx:Form x="20.5" y="10" width="442" height="300"&gt;<br /> 	&lt;mx:DataGrid x="74" y="76" id="datagrid1" width="407" height="229" dataProvider="{retorno}"&gt;<br /> 		&lt;mx:columns&gt;<br /> 			 &lt;mx:DataGridColumn dataField="nome" headerText="Product Id"/&gt;<br /> 		&lt;/mx:columns&gt;<br /> 	&lt;/mx:DataGrid&gt;<br /> 	&lt;mx:Button label="Button" click="clienteService.buscarTodosCliente"/&gt;<br /> 	&lt;mx:Label x="121" y="28" text="Label" width="108" id="labelTeste"/&gt;<br /> 	&lt;/mx:Form&gt;<br /> <br /> <br /> 	&lt;mx:RemoteObject id="clienteService" destination="clienteService"&gt;<br /> 		&lt;mx:method name="buscarTodosCliente" result="{converter(event.result)}"/&gt;<br /> 	&lt;/mx:RemoteObject&gt;<br /> 	<br /> 	&lt;mx:Script&gt;<br />         &lt;![CDATA[<br />         import mx.collections.ArrayCollection;<br />         [Bindable]<br />         public var retorno:ArrayCollection;<br />        <br />        public function converter(teste:Object):void{<br />         	labelTeste.text = "Entrei no metodo";<br />         	retorno =  teste (ArrayCollection);<br />         }<br />         <br />         ]]&gt;<br />     &lt;/mx:Script&gt;<br /> 	<br /> 	<br /> &lt;/mx:Application&gt;<br /> [/code]<br /> <br /> Se alguem tiver algum exemplo que possa me ajudar tambem sera bem vindo, mas que esteja usando o blazeds.<br /> <br /> valeu mais uma vez galera!]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197724/992341/pegar-um-list-do-banco
</guid>
				<link>http://www.guj.com.br/prepost/197724/992341/pegar-um-list-do-banco
</link>
				<pubDate><![CDATA[Tue, 9 Feb 2010 00:33:47]]> GMT</pubDate>
				<author><![CDATA[ vcsmetallica]]></author>
			</item>
			<item>
				<title>Re:Pegar um list do banco</title>
				<description><![CDATA[ Algumas correções para começar....<br /> <br /> 1 - Vc deve chamar o método colocando ()<br /> [code]&lt;mx:Button label="Button" click="clienteService.buscarTodosCliente()"/&gt;[/code]<br /> <br /> 2- Não se usa a expressão de binding para tratar eventos.<br /> [code]&lt;mx:method name="buscarTodosCliente" result="converter(event)"/&gt;[/code]<br /> <br /> 3- Receba o evento e atribua o resutado a variável. Lembrando que o "as" é uma das formas (de duas) de fazer cast. A outra seria ArrayCollection(minhaVar).<br /> [code]public function converter(event:ResultEvent):void{  <br />    labelTeste.text = "Entrei no metodo";  <br />    retorno =  event.result as ArrayCollection;  <br /> }  [/code]<br /> <br /> Verifique agora como fica...<br /> <br /> []s,<br /> ]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197724/992394/repegar-um-list-do-banco
</guid>
				<link>http://www.guj.com.br/prepost/197724/992394/repegar-um-list-do-banco
</link>
				<pubDate><![CDATA[Tue, 9 Feb 2010 08:44:27]]> GMT</pubDate>
				<author><![CDATA[ henrique.marino]]></author>
			</item>
			<item>
				<title>RESOLVIDO :Pegar um list do banco</title>
				<description><![CDATA[ henrique.marino <br /> <br /> funcionou colega!!!!<br /> <br /> Valeu pela ajuda!!!]]></description>
				<guid isPermaLink="true">http://www.guj.com.br/prepost/197724/992967/resolvido-pegar-um-list-do-banco
</guid>
				<link>http://www.guj.com.br/prepost/197724/992967/resolvido-pegar-um-list-do-banco
</link>
				<pubDate><![CDATA[Tue, 9 Feb 2010 22:16:09]]> GMT</pubDate>
				<author><![CDATA[ vcsmetallica]]></author>
			</item>
	</channel>
</rss>
