0
好吧,我通过WebOrb将一个复杂的对象从我的.NET库传递到我的Flex应用程序。 为了自动翻译,我使用[RemoteClass]元数据标记,如下所示:使用[RemoteClass]填充ArrayCollection属性
[RemoteClass(alias="test.PlanVO")]
public class Plan
{
[SyncId]
public var id:int;
public var Name:String;
}
这工作绝对没问题,直到我尽量延长计划类包含的复杂的项目的数组:
.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计划类的children属性也为null。
我试图改变孩子们现场像这样的属性:
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;
}
而是集功能不会被调用。
我能做些什么来让孩子们以这种方式进入我的Flex应用程序?
谢谢!
一个数组!当然! DUUUUUH! 非常感谢,只需将其从ArrayCollection更改为完美! – user176504 2010-07-13 16:35:10
很高兴帮助!如果你需要一个ArrayCollection,你总是可以添加一个像getChildrenAsArrayCollection这样的方法来为你做转换。不过,要注意向Flex类添加新属性,因为它可能会干扰自动AMF转换。 – JeffryHouser 2010-07-13 16:43:07