shawntng wrote:Understand that with RemoteObject + BlazeDS, we could access Java objects on the server.
I am able to return Java collections and native objects, but if i wish to return an ArrayList of customized Java Bean Object to Flex, how can i do it?
I read that we need FDS, but dont BlazeDS provides the funcationality?
I need a 100% free setup

, so i'm not into buying the Lifecycle stuff.
Anyone can advise?
Hi shawntng,
You can return return ArrayList of customised JavaBeans to Flex...
Here's how i do it with BlazeDS..
1) Specify this on a AS3 ValueObject [RemoteClass(alias="some.package.inyourjava.app.UserVO")]
2) Create custom get and set functions. Here's a quick example. Pardon me if it is not a really good one. Let's say we have a friendList ArrayCollection variable for each UserVO. The custom get set functions will automatically type cast your custom object from your BlazeDS result.
- Code: Select all
package package.vo
{
import com.adobe.cairngorm.vo.IValueObject; //Cairngorm
import mx.collections.ArrayCollection;
[Bindable]
[RemoteClass(alias="some.package.inyourjava.app.UserVO")]
public class UserVO implements IValueObject
{
public var userId:Number=0;
public var name:String;
public var _friendsList:ArrayCollection = new ArrayCollection();
}
public function set friendList(array:ArrayCollection):void{
var tempFriendList:ArrayCollection = new ArrayCollection();
for (var i:int = 0; i < array.length; i++) {
tempFriendList.addItem(UserVO(array.getItemAt(i)));
}
_userProfile = tempFriendList;
}
public function get friendList():ArrayCollection{
var tempFriendList:ArrayCollection = new ArrayCollection();
for (var i:int = 0; i < _friendsList.length; i++) {
tempFriendList.addItem(UserVO(_friendsList.getItemAt(i)));
}
_friendsList = tempUserProfileList;
return _friendsList;
}
}
3) You can use your friendList var with something like this
var user:UserVO = new UserVO();
user = event.result //assuming you get the result from BlazeDS
trace("FriendList: " + user.friendList);
Do note that BlazeDS security model is not really that secured.