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 閱讀(2133) 評論(0)  編輯  收藏


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


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

          導航

          統計

          公告

          welcome to my place.

          常用鏈接

          留言簿(5)

          我參與的團隊

          隨筆分類

          隨筆檔案

          新聞分類

          石頭JAVA擺地攤兒

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          @duduli
          主站蜘蛛池模板: 南华县| 开封市| 宜君县| 东安县| 宜城市| 青州市| 巩留县| 南阳市| 合水县| 平湖市| 巴中市| 白山市| 盐城市| 岑溪市| 四会市| 灵山县| 莱西市| 连山| 堆龙德庆县| 彰武县| 扎囊县| 定襄县| 西宁市| 辽阳县| 巨野县| 焦作市| 乌审旗| 兴海县| 莒南县| 太谷县| 锦屏县| 阳江市| 昌黎县| 静宁县| 靖边县| 昌江| 文安县| 龙南县| 翁源县| 安仁县| 红桥区|