网学网为广大网友收集整理了,Java Flex对象透明映射最佳实践2,希望对大家有所帮助!
最后一个是“JavaFlexMapping.mxml”文件,也就是我们的主程序界面:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="black" fontSize="12" verticalAlign="middle" horizontalAlign="center" color="#000506" creationComplete="init()">
<mx:RemoteObject id="lo" destination="listDAO" result="handleResult(event)" fault="handleFault(event)"> <mx:channelSet> <mx:ChannelSet> <mx:channels> <mx:AMFChannel
uri="http://127.0.0.1:8080/JavaFlexMapping/messagebroker/amf"/> </mx:channels> </mx:ChannelSet> </mx:channelSet> </mx:RemoteObject> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
var fg:FlexGroup;
var ac:ArrayCollection;
private function init():void{
//create FlexGroup instance for remote DAO
fg = new FlexGroup();
fg.groupName = "测试组";
fg.member1 = "成员1";
fg.member2 = "成员2";
fg.member3 = "成员3";
fg.member4 = "成员4";
fg.member5 = "成员5";
}
private function handleResult(event:ResultEvent):void{
ac = ArrayCollection(event.result);
dg.dataProvider = ac;
}
private function handleFault(event:FaultEvent):void{
Alert.show(event.fault.message, "出错了");
}
]]> </mx:Script> <mx:Panel height="364" width="592" title="Java Flex对象透明映射最佳实践" horizontalAlign="center" verticalAlign="middle"> <mx:VBox> <mx:ApplicationControlBar dock="true" width="551"> <mx:Button label="赶快点我 我就给数据" click="lo.getData(fg)"/> </mx:ApplicationControlBar> <mx:DataGrid height="255" width="551" id="dg"> <mx:columns> <mx:DataGridColumn headerText="组名" dataField="groupName"/> <mx:DataGridColumn headerText="成员一" dataField="member1"/> <mx:DataGridColumn headerText="成员二" dataField="member2"/> <mx:DataGridColumn headerText="成员三" dataField="member3"/> <mx:DataGridColumn headerText="成员四" dataField="member4"/> <mx:DataGridColumn headerText="成员五" dataField="member5"/> </mx:columns> </mx:DataGrid> </mx:VBox> </mx:Panel></mx:Application>&