java ArrayCollection 对象转换

2019-04-15 16:36发布

[img]http://dl.iteye.com/upload/picture/pic/116675/34c3d1b1-da6a-3318-aa90-612aae4d1ec4.jpg[/img]
package com.demo.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UserService {

public List getUserList() {
List resultList = new ArrayList();
for (int i = 1; i <= 10; i++) {
Map map = new HashMap();
map.put("id", i);
map.put("name", "name" + i);
map.put("age", 17 + i);
map.put("email", "China" + i + "@gmail.com");
resultList.add(map);
}
return resultList;
}
}


xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" creationComplete="init()">

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var list:ArrayCollection;
public function init():void{

UserService.getUserList();
}

protected function UserService_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
list=event.result as ArrayCollection;
}

]]>



endpoint="/DataServer/messagebroker/amf">
















xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" creationComplete="init()">

import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var message:String;
private var list:ArrayCollection;
public function init():void{

UserService.getUserList();
}

protected function UserService_resultHandler(event:ResultEvent):void
{
// TODO Auto-generated method stub
list=new ArrayCollection((event.result).toArray());
message=list.getItemAt(0).email;
}
]]>



endpoint="/DataServer/messagebroker/amf">