boa.
-- **************************************************** www.brunobg.com [email protected] (MSN & Skype) blogflex.brunobg.com @brunogrohs (21) 9913-2397 Em 1 de setembro de 2010 13:06, Mário Júnior <[email protected]>escreveu: > refatorando: > public function get nomeUsuario():String{ > return (usuario != null) ? usuario.nome : "usuário não informado"; > //ou apenas "" > } > > "null-safe" é sempre uma boa prática :) > > []s > > > > Em 1 de setembro de 2010 12:27, claudemir <[email protected]> escreveu: > >> Valeu pela ajuda bruno bg >> >> Segui a sua orientação e fiz assim e funcionou >> --- meu get >> public function get nomeUsuario():String{ >> var result:String = usuario.nome; >> return result; >> } >> >> --- coluna do datagrid >> <mx:DataGridColumn headerText="Usuario" dataField="nomeUsuario" /> >> >> Muito obrigado >> >> On 1 set, 10:17, bruno bg <[email protected]> wrote: >> > essa maneira {usuario.nome} só funciona no SDK 3.5 ou acima. >> > outras versões faça uso do LabelFunction ou itemRenderer ou crie um GET >> na >> > sua classe pagamento retornando o nome do usuário. >> > >> > um "pitaco", na sua classe USUARIO não precisa o atributo >> "listPagamentos >> > (array)" >> > na sua classe "pagamento" já tem atributo "Usuario (objeto)", vc pode >> fazer >> > um filtro com WHERE a partir do id do usuario e trazer todos os >> pagamentos >> > de um determinado Usuario. >> > >> > só um "pitaco". >> > >> > abração >> > -- >> > ****************************************************www.brunobg.com >> > [email protected] >> > blogflex.brunobg.com >> > @brunogrohs >> > (21) 9913-2397 >> > >> > Em 1 de setembro de 2010 09:52, claudemir <[email protected]> >> escreveu: >> > >> > > Bom dia >> > > No meu dataGrid tenho uma lista de pagamento e cada pagamento >> > > pertence a um usuario, no entanto não sei como mostrar o nome do >> > > usuario no dataGrid, Tentei fazer assim mas não mostrou nada. >> > > <mx:DataGridColumn headerText="Usuario" dataField="usuario.nome" /> >> > > </mx:columns> >> > >> > > Segue abaixo as minhas classes. >> > >> > > package com.digows.artigos.JavaFlex.view.entity >> > > { >> > > import mx.collections.ArrayCollection; >> > >> > > >> [RemoteClass(alias="com.digows.artigos.JavaFlex.model.entity.Usuario")] >> > > [Bindable] >> > > public class Usuario >> > > { >> > > public var id:Number; >> > > public var nome:String; >> > > public var login:String; >> > > public var senha:String; >> > >> > > public var listPagamentos:ArrayCollection; >> > >> > > public function Usuario() >> > > { >> > > listPagamentos = new ArrayCollection(); >> > > } >> > >> > > } >> > > } >> > >> > > >> ----------------------------------------------------------------------------------------- >> > > package com.digows.artigos.JavaFlex.view.entity >> > > { >> > >> > > >> [RemoteClass(alias="com.digows.artigos.JavaFlex.model.entity.Pagamento")] >> > > [Bindable] >> > > public class Pagamento >> > > { >> > > public var id:Number; >> > > public var dataPagamento:Date; >> > > public var dataVencimento:Date; >> > > public var valorPagamento:Number; >> > > public var valorVencimento:Number; >> > > public var obs:String; >> > > public var status:Status; >> > > public var usuario:Usuario; >> > >> > > public function Pagamento() >> > > { >> > > status = new Status(); >> > > usuario = new Usuario(); >> > > this.status = status; >> > > } >> > >> > > } >> > > } >> > >> > > <?xml version="1.0" encoding="utf-8"?> >> > > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" >> > > creationComplete="getList()" width="100%" height="100%"> >> > >> > > <mx:Panel id="panelPagamento" layout="absolute" title="Controle >> de >> > > Pagamento teste" width="100%" height="100%"> >> > >> > > <mx:Label text="Id:" x="10" y="10"/> >> > > <mx:TextInput id="idTxt" editable="false" >> enabled="false" >> > > text="{Pagamento(dgPagamento.selectedItem).id}" x="34" y="8" >> > > width="72"/> >> > >> > > <mx:Label text="Pagamento" x="124" y="10"/> >> > >> > > <mx:Label text="Vencimento" x="124" y="36"/> >> > > <mx:DateField id="dtdataPagamento" >> formatString="DD/MM/YYYY" >> > >> > > >> text="{dateFormatter.format(Pagamento(dgPagamento.selectedItem).dataPagamento)}" >> > > x="201" y="34" width="107" /> >> > >> > > <mx:DateField id="dtdataVencimento" formatString="DD/MM/YYYY" >> > >> > > >> text="{dateFormatter.format(Pagamento(dgPagamento.selectedItem).dataVencimento)}" >> > > x="201" y="8" width="107" /> >> > >> > > <mx:TextInput id="valorPagamentoTxt" >> > > text="{Pagamento(dgPagamento.selectedItem).valorPagamento}" x="375" >> > > y="8" width="133"/> >> > > <mx:Label text="Valor" x="334" y="10"/> >> > > <mx:Label text="Valor" x="334" y="36"/> >> > > <mx:TextInput id="valorVencimentoTxt" >> > > text="{Pagamento(dgPagamento.selectedItem).valorVencimento}" x="375" >> > > y="34" width="133"/> >> > >> > > <mx:ComboBox id="combo_usuarios" >> > > dataProvider="{listUsuarios}" >> > > labelField="nome" x="201" y="64" width="211" /> >> > >> > > <mx:DataGrid id="dgPagamento" >> > > dataProvider="{listPagamentos}" width="100%" >> > > height="130" y="94"> >> > > <mx:columns> >> > > <mx:DataGridColumn headerText="ID" >> > > width="30" dataField="id"/> >> > > <mx:DataGridColumn >> headerText="Pagamento" >> > > dataField="dataPagamento" labelFunction="formatDate"/> >> > > <mx:DataGridColumn headerText="Valor" >> > > dataField="valorPagamento" / >> > >> > > <mx:DataGridColumn >> headerText="Vencimento" >> > > dataField="dataVencimento" labelFunction="formatDate"/> >> > > <mx:DataGridColumn headerText="Valor" >> > > dataField="valorVencimento" >> > > labelFunction="formatMoney" /> >> > > <mx:DataGridColumn headerText="Usuario" >> > > dataField="usuario.nome" / >> > >> > > </mx:columns> >> > > </mx:DataGrid> >> > > <mx:ControlBar horizontalAlign="center"> >> > > <mx:Button label="Novo" id="btNovo" >> click="setDefault()" >> > > icon="@Embed('icons/novo2.jpg')"/> >> > > <mx:Button label="Salvar" id="btSalvar" click="save()" >> > > icon="@Embed('icons/save12.jpg')"/> >> > > <mx:Button label="Excluir" id="btExcluir" >> click="remove()" >> > > icon="@Embed('icons/delete_lixo_10.jpeg')"/> >> > > </mx:ControlBar> >> > >> > > </mx:Panel> >> > >> > > <mx:CurrencyFormatter id="moneyFormatter" precision="2" >> > > rounding="none" >> > > decimalSeparatorTo="," thousandsSeparatorTo="." >> > > useThousandsSeparator="true" useNegativeSign="true" >> > > currencySymbol="$ " >> > > alignSymbol="left"/> >> > >> > > <mx:DateFormatter id="dateFormatter" formatString="DD/MM/YYYY" >> /> >> > >> > > <mx:RemoteObject id="pagamentoService" showBusyCursor="true" >> > > fault="onFault(event)" destination="pagamentoService"> >> > > <mx:method name="save" result="onResultSave(event)" >> > > fault="onFault(event)"/> >> > > <mx:method name="remove" result="onResultRemove(event)" >> > > fault="onFault(event)"/> >> > > <mx:method name="getList" >> result="onResultGetList(event)" >> > > fault="onFault(event)"/> >> > > <mx:method name="getListUsuarios" >> > > result="onResultGetListUsuarios(event)" fault="onFault(event)"/> >> > > <mx:method name="aviso" result="onResultGetList(event)" >> > > fault="onFault(event)"/> >> > > </mx:RemoteObject> >> > >> > > <mx:Script> >> > > <![CDATA[ >> > > import >> > > com.digows.artigos.JavaFlex.view.entity.Usuario; >> > > import >> > > com.digows.artigos.JavaFlex.view.entity.Status; >> > > import >> > > com.digows.artigos.JavaFlex.view.entity.Pagamento; >> > > import >> > > com.digows.artigos.JavaFlex.view.entity.Pagamento; >> > > import mx.collections.ArrayCollection; >> > > import mx.rpc.events.ResultEvent; >> > > import mx.rpc.events.FaultEvent; >> > > import mx.controls.Alert; >> > > import mx.utils.ObjectUtil; >> > >> > > [Bindable] >> > > private var listPagamentos:ArrayCollection; >> > > [Bindable] >> > > private var listUsuarios:ArrayCollection; >> > >> > > private var pagamento:Pagamento; >> > >> > > private var usuario:Usuario; >> > >> > > public function save():void >> > > { >> > >> > > //Alert.show(combo_usuarios.selectedItem.data.toString()); >> > > this.pagamento = new Pagamento(); >> > > this.pagamento.dataPagamento = >> > > dtdataVencimento.selectedDate; >> > > this.pagamento.dataVencimento = >> > > dtdataPagamento.selectedDate; >> > > this.pagamento.valorPagamento = >> > > Number(valorPagamentoTxt.text); >> > > this.pagamento.valorVencimento = >> > > Number(valorVencimentoTxt.text); >> > > this.pagamento.obs = "teste"; >> > > // Pegar o usuario selecionado >> > > this.pagamento.usuario = >> > > combo_usuarios.selectedItem as Usuario; >> > > //Chama o metodo Save do servico >> > > "cargoService" >> > > pagamentoService.save(pagamento); >> > > } >> > >> > > private function >> > > getListUsuariosResultHandler(event:ResultEvent):void >> > > { >> > > listUsuarios = event.result as ArrayCollection; >> > > combo_usuarios.dataProvider(listUsuarios); >> > > } >> > >> > > //Função que será executada após a conclusão do >> > > método save >> > > public function >> onResultSave(event:ResultEvent):void >> > > { >> > > status = "Salvo com Sucesso! Ultima ID: >> > > "+Pagamento(event.result).id; >> > > getList(); >> > > } >> > >> > > public function remove():void >> > > { >> > > if (dgPagamento.selectedItem != null) { >> > > pagamento = >> dgPagamento.selectedItem >> > > as Pagamento; >> > > >> pagamentoService.remove(pagamento); >> > > } else { >> > > Alert.show("Selecione um Item >> na >> > > DataGrid"); >> > > } >> > > } >> > >> > > //Função que será executada após a conclusão do >> > > método remove >> > > public function >> > > onResultRemove(event:ResultEvent):void >> > > { >> > >> > ... >> > >> > mais » >> >> -- >> Você recebeu esta mensagem porque está inscrito na lista "flexdev" >> Para enviar uma mensagem, envie um e-mail para [email protected] >> Para sair da lista, envie um email em branco para >> [email protected] >> Mais opções estão disponíveis em http://groups.google.com/group/flexdev >> > > > > -- > Mario Junior > http://blog.mariojunior.com/ > @mariojunior > > -- > Você recebeu esta mensagem porque está inscrito na lista "flexdev" > Para enviar uma mensagem, envie um e-mail para [email protected] > Para sair da lista, envie um email em branco para > [email protected] > Mais opções estão disponíveis em http://groups.google.com/group/flexdev -- Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para [email protected] Para sair da lista, envie um email em branco para [email protected] Mais opções estão disponíveis em http://groups.google.com/group/flexdev
