mattb
|
|
« on: January 25, 2009, 03:24:35 » |
|
Hi, we have just started with FLex and PureMVC and we are have come across an issue regarding registering mediators to states of a component.
An MXML component has various states. Each state is another MXML that is wrapped in an AddChild tag. Each state component contains buttons, input fields, labels etc and has properties that are binded to the labels, tooltips etc.
A Mediator is instantiated for the main component and registered with the facade. Each state component has a mediator who's constructor sets the binded properties.
The issue we have is WHEN should register the mediators for each state.?
If we register the mediator for each state view at the same time as we register the mediator for the main component we get null object reference errors at run time. I'm not sure of the null object is the the state, or the binded properties within the states view.
The way we have got round it is to wait for the "creationComplete" event of each state component to fire, then send that to the Main component mediator.
This then sends a note to trigger a command that will register the appropriate mediator for the state component that has just loaded.
However we end up with an extra command that checks the note for which state view has just loaded and then register its Mediator and send a note to set the binded properties for the labels etc in the view.
I was wondering if we are missing something, is there a way to register these mediators without having to have the creationComplete events and extra commands to handle them?
Should we simply have the "creationComplete" event trigger a handler in the mediator that then registers its mediator and NOT have a command that does this?
Is there a totally different approach?
I can post some examples if that is needed.
Thanks in advance, Matt.
|