PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: Arno on July 22, 2009, 11:53:42



Title: How to register mediator on run with tree navigation
Post by: Arno on July 22, 2009, 11:53:42
I have an application that has a large number of views so I use a viewstack and a tree as menu. But like in the Slacker example I can't just set a dispatch event on every menu item. So how can I know in the mediator what item is clicked without writing code double or have a switch statement?

I hope I explained it good enough


Title: Re: How to register mediator on run with tree navigation
Post by: puremvc on July 26, 2009, 10:44:42
Have the view component that contains the tree handle the ITEM_CLICKED event, investigate the target property and set a public property on the view component exposing a reference to the item clicked. Then send a corresponding event that the mediator is interested in. The mediator looks at the exposed public property on its view component to know what was clicked and doesn't need to know about the tree.

-=Cliff>


Title: Re: How to register mediator on run with tree navigation
Post by: isragaytan on July 29, 2009, 05:38:00
And dont forget in the Custom Event to put in the constructor:

super(evt,true,true)

for bubbling.

Cheers