Galera,
Sou novato em Flex.
Estou querendo pegar uma lista do banco e colocar em grid no flex. Estou usando o BlazeDS.
Abaixo segue o meu codigo.
Nao sei onde estou errando. Tem alguma maneira mais facil de fazer sem ser essa que estou tentando fazer?
Outra coisa, nao esta lancando nenhum erro, simplesmente nao funciona.
Classe cliente.java
package br.com.ces.sgmv.entity;
public class Cliente {
private String nome;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
Meu Service, aqui estou simulando como se estivesse pegando do bando de dados.
import java.util.ArrayList;
import java.util.List;
import br.com.ces.sgmv.entity.Cliente;
public class ClienteService {
public List<Cliente> buscarTodosCliente(){
List<Cliente> list = new ArrayList<Cliente>();
try {
for(int i = 0; i < 20; i++){
Cliente cliente = new Cliente();
cliente.setNome("cliente" + i);
list.add(cliente);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
}
Meu ActionScript relacionado a classe cliente em java
package br.com.ces.sgmv.flex.dto.modelo
{
[RemoteClass(alias="br.com.ces.sgmv.entity.Cliente")]
public class Cliente
{
public var nome:String;
}
}
O trecho que estou usando no meu remoteconfig
<destination id="clienteService">
<properties>
<source>br.com.ces.sgmv.service.ClienteService</source>
</properties>
</destination>
e por fim o meu mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:dto="br.com.ces.sgmv.flex.dto.modelo.*"
layout="absolute">
<mx:Form x="20.5" y="10" width="442" height="300">
<mx:DataGrid x="74" y="76" id="datagrid1" width="407" height="229" dataProvider="{retorno}">
<mx:columns>
<mx:DataGridColumn dataField="nome" headerText="Product Id"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Button" click="clienteService.buscarTodosCliente"/>
<mx:Label x="121" y="28" text="Label" width="108" id="labelTeste"/>
</mx:Form>
<mx:RemoteObject id="clienteService" destination="clienteService">
<mx:method name="buscarTodosCliente" result="{converter(event.result)}"/>
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var retorno:ArrayCollection;
public function converter(teste:Object):void{
labelTeste.text = "Entrei no metodo";
retorno = teste (ArrayCollection);
}
]]>
</mx:Script>
</mx:Application>
Se alguem tiver algum exemplo que possa me ajudar tambem sera bem vindo, mas que esteja usando o blazeds.
valeu mais uma vez galera!