Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Multiple viewComponents for Mediators  (Read 9066 times)
dfstewart3
Newbie
*
Posts: 3


View Profile Email
« on: April 18, 2008, 12:47:58 »

You have stated that a Mediator can manage more than one viewComponent.  Can you please give me a code example of this?  I want to use a popup window along with my viewComponent and manage both with the same Mediator - the popup window has comboBoxes for which I want to create and set the dataProviders in the Mediator.  Is this possible?

Thanks,
Donna
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: April 18, 2008, 03:18:33 »

Have a look at the AppControlBarMediator in the AS3/AIR example called CodePeek.


-=Cliff>
Logged
dfstewart3
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: April 21, 2008, 07:39:26 »

Thank you for your response.  Unless I am missing something, it appears to me that I will need a separate mediator for my titlewindow instead of being able to manage the titlewindow within my existing mediator for the main viewcomponent.  It looked to me as if the AppControlBarMediator only handles the AppControlBar viewcomponent, not multiple viewcomponents.  If I am missing something, please let me know.  Otherwise, I will create a mediator for my titlewindow and cast the viewcomponent to the actual titlewindow type.  Thank you again for your  help.

Donna
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: April 21, 2008, 08:24:43 »

The AppControlBarMediator manages multiple components; all those within the AppControlBar. But technically it has only  one viewComponent property.

Note that in beginSearch

:
private function beginSearch( event:Event=null ):void
        {
            codeSearchProxy.search( controlBar.searchTI.text, controlBar.searchCombo.selectedItem );
        }

It actually references the components within the controlbar. Note that this IS NOT a best practice, but illustrates that it is possible for the Mediator to be as aware of the internals of the view component as necessary. A better way to do this would be to bind the values being read into public properties on the controlbar so the mediator is not aware of the internals. This makes the component more portable, but would have made the demo less readable.

For handling a popup, you might want to read this article: http://www.nutrixinteractive.com/blog/?p=76

-=Cliff>


Logged
dfstewart3
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: April 21, 2008, 08:32:14 »

I got you.  Looks like I need to revisit more of my code to incorporate the best practices.  :P  My title of newbie definitely fits.  :) I really appreciate your  help.
Logged
Pages: [1]
Print