Not so long ago I was working with the XIFF library again and I needed to show a list of contacts.
The contact datum is represented in XIFF as an ArrayCollection containing ArrayCollections.
Roster extends ArrayCollection and contains a property called ‘groups’ which also extends ArrayCollection.
The ‘groups’ ArrayCollection contains RosterGroup items, which also extend ArrayCollection, and each of these contain RosterItemVO’s (the actual contact).
The RosterGroup ArrayCollection represent the groups that you arrange your contacts in, including an offline group, and a RosterItemVO represents an individual contact.
So we have something like…
[code]
[/code]
I took a look at what they were doing in SparkWeb, but they had, what seemed to me, an extremely complicated way of displaying the data, when a Tree control should be able to do the job, the only problem being that a Tree didn’t want to work with ArrayCollections. To the rescue ArrayCollectionDataDescriptor!
ArrayCollectionDataDescriptor Example (right click for example source)
As you can see in the example, the objects passed into the Tree as the dataProvider need to have a property to be used at the label, so you can’t use an ArrayCollection as it is (if you do, it’ll do toString() on it for the label of the folder and you’ll get a list of your objects), so you just need to extend ArrayCollection (as they have in XIFF) and give it a property to use for the label.
The source for the ArrayCollectionDataDescriptor can be found in our Google Code Library.