ColdFusion and Flex, composite CFCs, and Arrays

I have ran across this issue before and seem to have finally come across a solution. The issue: say I have a CFC called Person which has a property addressArray that is a array of Address CFCs. In my Flex app the associated Person.as object should have

addressArray:ArrayCollection();

But this does not work.

addressArray:Array();

Will work though, but now I loose all that fancy schtuff in ArrayCollections, eh? So, in short the array does not translate into a ArrayCollection, but just a Array. Now this is expected behaviour, but how to get the ArrayCollection to work? Custom accessors and mutators! In Person.as modify the above to the below:

_addressArray:ArrayCollection();
[Bindable(event="addressArrayChanged")]
public function get addressArray():Object {
return _addressArray as ArrayCollection;
}
public function set addressArray( value:Object):void {
_addressArray = new ArrayCollection(value as Array);
var eventObj:Event = new Event("addressArrayChanged");
dispatchEvent(eventObj);
}

HTH!

DK

This entry was posted in ColdFusion, Flex, Techy. Bookmark the permalink.

One Response to ColdFusion and Flex, composite CFCs, and Arrays

  1. Kenny S. says:

    Great work. Big time saver here. Thanks Douglas.

Comments are closed.