views:

29

answers:

1

I'm trying to populate a mx:tree component with values that I'm getting from BlazeDS. The returned data from BlazeDS is fine - it's an ArrayCollection of Folder value objects.

I've been instructed to use Cairngorm for this project. I'm pretty new to Flex and Cairngorm. According to the limited documentation that I've read online I should populate the model with data so I've stuck the array collection there.

What I'm stuck with is trying to update the tree component. I feel that I need some way to notify the container component for the tree that the data (i.e. the subfolders) is available on the model. I was hoping that it would be possible to fire a function in the container component to add the subfolders as children of the selected node (I could chuck this on the model before the remote object call I guess) then fire tree.invalidateList() and tree.validateNow(). Any ideas?

A: 

I found a way to do this although I'm not sure if this is the recommended way.

I got the Command class to stick the ArrayCollection of Folder VOs to a property called 'subfolders' on the model. I used a ChangeWatcher in the tree's parent container to watch the model's 'subfolders' property and fire a function to update the tree node when required.

If someone knows of a better way, please tell. I was hoping to find a Cairngorm cookbook or best practices article but I've not stumbled upon such a thing yet. Cairngorm documentation seems pretty sparse - I'm surprised that it's the most popular Flex framework given this fact.

ukdavo