We are struggling with the correct (Best Practice) way to handle our deeply nested classes when binding fails. We are thinking that often these failures are due to ItemPending Errors which is why I have included that as part of the topic. Here is our challenge.
We have MANY deeply nested objects. For example, A BusinessEntityVO contains a collection of RelationshipVO's A RelationshipVO contains a ContactVO A ContactVO contains a collection of emails, phones and addresses An EmailVO contains an address (String) & type (String) Then we have a bunch of getters...for example In BusinessEntity, there is a getter called DefaultEmail. This getter looks for a defaultRelationship. If that is not set, AND there is at least one Relationship in the collection, then it get's the first Relationship in the collection and calls it's getter defaultEmail (which does a similar call in the RelationshipVO.) These work great...WHEN all the data is present and loaded on the client AND the underlying data doesn't change... (of course this never is the case!) Here are the two problems. 1) THE UNDERLYING DATA CHANGES: Due to the deeply nested natures of these properties and the binding limitations with getters, we are looking for a way to get all this information back out to the views when needed. Is there some code we could write in each of the VO's that can bubble up the chain to eventually refresh the views? We have experimented with a couple different approaches but are looking for some advice as far as a best practice on this one. We tried dispatching our own events, but this didn't seem to solve the problem when collections are bound to DataGrids and Lists, etc... maybe we were doing it wrong... 2) THE DATA IS PENDING: We think that some of the binding is failing simply because of ItemPending Errors. Is is best practice to look for and handle these errors inside the getters of the VO? If so are there any examples of how best to do this? It seems like the VO is the best place to handle these errors so that if a call for the getter defaultEmail is made and the email is not available yet, the VO handles the error and refreshes the call once the Email has arrived. Has anyone had experience with this before? Is there a sound approach? Lastly, I would love to hear how other's handle the binding of deeply nested properties and collections. People often comment that they set things explicitly instead of using binding or getters, but it seems counter to Flex and OOP (and also a huge pain), especially when dealing with large amounts of itemRenderers, etc... There has to be a better way. Thanks for listening. - Kevin