使用 [RemoteClass] 填充 ArrayCollection 属性

发布于 2024-09-08 22:29:54 字数 1392 浏览 6 评论 0原文

好的,我正在通过 WebOrb 将一个复杂对象从 .NET 库传递到我的 Flex 应用程序。 为了自动翻译,我使用 [RemoteClass] 元数据标记,如下所示:

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

    public var Name:String;
}

这绝对可以正常工作,直到我尝试扩展 Plan 类以包含复杂项目的数组:

.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;
}

在这种情况下,甚至当 .NET 库返回子级时,ActionScript Plan 类的 Children 属性为 null。

我尝试将 Children 字段更改为如下属性:

private var _children:ArrayCollection;
public function get children():ArrayCollection 
{
    return _children;
}
public function set children(o:*):void
{
    if(o is ArrayCollection)
        _children = o;
    else if(o is Array)
        _children = new ArrayCollection(o);
    else
        _children = null;
}

但 set 函数永远不会被调用。

我该怎么做才能让孩子们以这种方式进入我的 Flex 应用程序?

谢谢!

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 ArrayCollection)
        _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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧笙踏歌 2024-09-15 22:29:54

set 方法从未被调用,这对我来说并不奇怪。理论上,该对象应该从服务器返回,其中的项目已设置。

也就是说,我不认为 ArrayCollection 会与服务器端对象匹配。尝试在 Flex 中使用数组。在 .NEt 中,您应该使用“受支持”的类型之一。如果 List 是 IList 的实现,那么您可能没问题。

这是.NET 到 Flash Player WebORB 转换表< /a>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文