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
          主站蜘蛛池模板: 宜兴市| 泾川县| 三门县| 盐源县| 民县| 南宁市| 白城市| 建水县| 翁牛特旗| 黄梅县| 绍兴市| 来宾市| 新绛县| 嘉善县| 灵宝市| 花垣县| 开平市| 甘孜县| 益阳市| 商洛市| 云林县| 靖边县| 普宁市| 镇江市| 将乐县| 大厂| 西林县| 伊金霍洛旗| 八宿县| 沂水县| 长兴县| 台南市| 澎湖县| 山东省| 烟台市| 镇远县| 黔西| 郧西县| 秦安县| 红桥区| 襄垣县|