The back end also has a Java user object class that serializes the user object in the list into XML data using the XStream component. obtained using the E4X format format on the flex side via Httpservice.
Just started to parse XML by E4X technology, and construct flex user object, similar to the way it was handled:
Copy Code code as follows:
Public Function FromXml (currentnode:xml): void{
UserID = new number (Currentnode.userid);
UserName = Currentnode.username;
......
}
But this way is too cumbersome. So I wanted to use flex reflect to implement a generic convert or a component like XStream.
Of course, the first is to Google one, and really found two, one is Xmlconverter (http://www.customware.net/repository/display/FLEX/Integrating+Flex+with +xml+using+xmlconverter), one is fully compatible with Xtream asx3m (http://code.google.com/p/asx3m/).
Xmlconverter simple, but not open source, for parsing a single object's XML format, or enough, but for parsing complex inclusion list structure, can not help. Finally, the use of asx3m, very convenient. The only thing that bothers me is that asx3m needs to rely on the Vegas (http://vegas.googlecode.com/svn/AS3/trunk/src/vegas/) behemoth (in fact, it only needs hashmap, List and several auxiliary classes)
Using asx3m is really handy, and the code at both ends is simple, as follows:
Server-side Java code:
list<workitem> users = um.queryusers (1);
XStream XStream = new XStream ();
Xstream.alias ("User", User.class);
String XML = xstream.toxml (users);
list<workitem> users = um.queryusers (1);
XStream XStream = new XStream ();
Xstream.alias ("User", User.class);
String XML = xstream.toxml (users);
Flex End as code:
Import hr.binaria.asx3m.Asx3m;
Import Hr.binaria.asx3m.Asx3mer;
var xmlc:asx3mer = asx3mer.instance;
Xmlc.xstream.alias ("user", user);
This array is the list of user objects
var array:arraycollection = Xmlc.fromxml (compxml) as arraycollection;
Import hr.binaria.asx3m.Asx3m;
Import Hr.binaria.asx3m.Asx3mer;
var xmlc:asx3mer = asx3mer.instance;
Xmlc.xstream.alias ("user", user);
This array is the list of user objects
var array:arraycollection = Xmlc.fromxml (compxml) as arraycollection;
It's as simple as that. -Of course, in this way, you need to maintain two sets of object structures (Java object) and (as Object) at both ends, but they are much more scalable and flexible than the remoteobject of the AMF.