PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: justSteve on June 11, 2008, 04:49:48



Title: Handling non-pureMVC-ized subcomponents
Post by: justSteve on June 11, 2008, 04:49:48
I have an MXML view component implementing a menu where 'upstream functions' like startup and dataprovider population are standard pureMVC operations. The buttons used by this menu are created by a reasonably complex 3rd party .as class that knows nothing of pureMVC. My menu (the pureMVC view component) is correctly injecting the dataProvider and another property required by the button class (labelField) when it declares the button object:

:
<mx:Canvas id="contentCanvas" top="10" width="200">
<nav:UFMButtonList id="nav" y="200"
width="200" maxHeight="800"
labelField="@ModuleName" visible="true"
showEffect="{myWD}" hideEffect="{myWU}"
filters="{dsFilterArray}"
openDuration="500"
/>
</mx:Canvas>


So far, so good. Now I need to modify the button component so that click  events (but only _some click events) are bubbled up to the menu component or even the the menu's mediator without incurring the complexity of making the button component a full-fledged pureMVC-ized class. I want to change just enough button code so that, at a given condition internal to the button object, the click event is passed back to the menu component or perhaps, the menu's mediator.

In other words, add a property to the button's declaration that tells the button's internal click hander where to send events that meet my conditions. To my eye, this is the same pattern as sending a 'responder' argument from a proxy to the constructor of a delegate letting the delegate know who gets the results of an asynch operation.

thoughts?

thx
--steve...


Title: Re: Handling non-pureMVC-ized subcomponents
Post by: puremvc on June 11, 2008, 07:35:21
There's no need for any view component to be a 'full-fledged PureMVC class'. Its nice if you internally encapsulate things so the mediator doesn't have to know much about the view component, but that's about it. You can pretty much do what you want inside the black box.

-=Cliff>


Title: Re: Handling non-pureMVC-ized subcomponents
Post by: philipSe on June 11, 2008, 08:52:27
Your button component can dispatch an event that can bubble up through the component hierarchy.  In the menu mediator, you can add an event listener to your menu component, the event listener being in the mediator as usual.  The menu component will see the event, provided the button component is below it in the hierarchy.  Does this help?  Have I misunderstood?
----Philip