flex中對Java返回list類型的處理

          后臺的Java程序返回一個list類型而前臺的的flex對其進行讀取,這個該怎么辦呢?
          返回list的Java代碼

           1 package com.duduli.li;
           2 
           3 import java.util.ArrayList;
           4 import java.util.Date;
           5 import java.util.List;
           6 
           7 public class Testlist {
           8     @SuppressWarnings("unchecked")
           9     public List returnList(){
          10 
          11         Perl p = new Perl();
          12         p.setId(1);
          13         p.setName("tom");
          14         p.setDate(new Date());
          15 
          16         Perl p2 = new Perl();
          17         p2.setId(2);
          18         p2.setName("john");
          19         p2.setDate(new Date());
          20 
          21         Perl p3 = new Perl();
          22         p3.setId(3);
          23         p3.setName("cate");
          24         p3.setDate(new Date());
          25     
          26         List<Perl> list = new ArrayList();
          27         list.add(p);
          28         list.add(p2);
          29         list.add(p3);
          30         
          31         return list;
          32     }
          在remoting-config.xml注冊好。
          1     <destination id="returnlist">
          2         <properties>
          3             <source>com.duduli.li.Testlist</source>
          4         </properties>
          5     </destination>
          前臺的flex用一個DataGrid來顯示
          使用remoteobject,調用注冊的destination。
          <mx:RemoteObject id="rl" destination="returnlist" result="resultHandler(event)"/>
          結果由result="resultHandler(event)"的方法處理
          下面就是關鍵的代碼了
           1     [Bindable]
           2         public var ac:ArrayCollection = null;
           3         
           4          public function bind():void{
           5             rl.returnList();
           6         }  
           7         
           8        private function resultHandler(event:ResultEvent):void {
           9             ac = ArrayCollection(event.result);
          10         } 
          下面則是顯示的
          1         <mx:DataGrid x="205" y="303" dataProvider="{ac}" creationComplete="bind()">
          2                 <mx:columns>
          3                         <mx:DataGridColumn headerText="id" dataField="id"/>
          4                         <mx:DataGridColumn headerText="name" dataField="name"/>
          5                         <mx:DataGridColumn headerText="date" dataField="date"/>
          6                 </mx:columns>
          7         </mx:DataGrid>
          其中creationComplete="bind()"是在程序運行的時候進行調用的(我是這樣認為的)。

          posted on 2009-04-20 10:19 duduli 閱讀(2130) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2009年4月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          導航

          統計

          公告

          welcome to my place.

          常用鏈接

          留言簿(5)

          我參與的團隊

          隨筆分類

          隨筆檔案

          新聞分類

          石頭JAVA擺地攤兒

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          @duduli
          主站蜘蛛池模板: 济南市| 开平市| 达日县| 丰顺县| 柳州市| 南涧| 双鸭山市| 防城港市| 巨野县| 关岭| 泉州市| 广元市| 区。| 六盘水市| 宣化县| 东丽区| 永丰县| 拜泉县| 邢台县| 宜宾市| 赣州市| 杨浦区| 收藏| 富源县| 浦江县| 陇西县| 姚安县| 西峡县| 永济市| 昆明市| 额济纳旗| 曲水县| 甘孜| 进贤县| 扶沟县| 金阳县| 兰州市| 开鲁县| 新巴尔虎右旗| 长顺县| 怀化市|