开发者

Populating an ArrayCollection property using [RemoteClass]

OK, I am passing a complex object from my .NET library to my Flex application via WebOrb. In order to automatically translate, I am using the [RemoteClass] meta data tag as follows:

[RemoteClass(alias="test.PlanVO")]
public class Plan
{
    [SyncId]
    public var id:int;

    public var Name:String;
}

This works absolutely fine, until I try to extend the Plan class to contain an array of complex items:

.NET:

public class PlanVO
{
    public int id  { get; set; }
    public string Name { get; set; }
    public List<PlanElementVO> children { get; set; }
}

public class PlanElementVO
{
    public string elementName { get; set; }
}

ActionScript:

[RemoteClass(alias="test.PlanVO")]
public class Plan
{
    [SyncId]
    public var id:int;

    public var Name:String;

    public var children:ArrayCollection;
}

[RemoteClass(alias="test.PlanElementVO")]
public class PlanElement
{
    public var elementName:String;
}

In this case, even when children are returned by the .NET library, the children property of the ActionScript Plan class is null.

I have tried changing the children field to a property like this:

private var _children:ArrayCollection;
public function get children():ArrayCollection 
{
    return _children;
}
public function set children(o:*):void
{
    if(o is Arr开发者_开发百科ayCollection)
        _children = o;
    else if(o is Array)
        _children = new ArrayCollection(o);
    else
        _children = null;
}

but the set function never gets called.

What can I do to get the children into my Flex app in this way?

Thanks!


It's no surprise to me that the set method s never called. The object should, theoretically, return from the server with the items already set.

That said, I did not think that an ArrayCollection would match to a server side object. Try using an Array in Flex. In .NEt you should use one of the "supported" types. If List is an implementation of IList, then you're probably fine.

Here is the .NET to Flash Player WebORB Conversion Chart

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜