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: Nested View - Manage Mediators.  (Read 12582 times)
yeremy
Jr. Member
**
Posts: 11


View Profile Email
« on: July 31, 2008, 01:52:07 »

hi All!

i've been doing small apps to understand pureMVC, i thing i got the general Idea.
now i'm working in a product catalog (the FlexStore) and i have a problem to register the Mediators.

i have the following view hierarchy :

-MyAPP.mxml
   - ProductView.mxml
      - ProductCatalogPanel.mxml
          - ProductCatalogThumbnail.mxml
      - ProductCart.mxml
      - ProductFilterPanel.mxml
   - LoginPanel.mxml

and i have the following Mediators :

-ApplicationMediator.as ( MyAPP.mxml )
    which registers the LoginPanelMediator.as (LoginPanel.mxml) and the ProductViewMediator (ProductView.mxml).

my question is  :
where should i  register the ProductCatalogPanelMediator (ProductCatalogPanel.mxml) and ProductCatalogThumbnailMediator.as (ProductCatalogThumbnail.mxml)


i'm trying to register ProductCatalogPanelMediator.as in the ProductViewMediator's constructor Method :

 
:
public class ProductViewMediator extends Mediator implements IMediator
{
public static const NAME : String = "ProductViewMediator";

public function ProductViewMediator(viewComponent:Object=null)
{
super(NAME, viewComponent);
facade.registerMediator( new ProductCatalogPanelMediator( productView.catalogPanel ) );
}

public function get productView(): ProductView
{
return viewComponent as ProductView;
}
}

i didn't get an error with this...but when i want to reference to ProductCatalogPanelMediator's viewcomponent  (with the get property) inside ProductCatalogPanelMediator, the reference is null...i mean :

:
public class ProductCatalogPanelMediator extends Mediator implements IMediator
{
public static const NAME : String = "ProductCatalogPanelMediator";

private var productProxy : ProductProxy;

public function ProductCatalogPanelMediator(viewComponent:Object=null)
{
super(NAME, viewComponent);

productProxy = facade.retrieveProxy( ProductProxy.NAME ) as ProductProxy;
}

public function get productCatalogPanel():ProductCatalogPanel
{
return viewComponent as ProductCatalogPanel;
}

/*----------  Own Methods----------*/
private function doSomething():void
        {
           
            if (productCatalogPanel.thumbnails != null){} //here
productCatalogPanel in null
}


}
in that part productCatalogPanel is null.

thanks!
« Last Edit: July 31, 2008, 02:07:44 by yeremy » Logged
yeremy
Jr. Member
**
Posts: 11


View Profile Email
« Reply #1 on: July 31, 2008, 02:05:15 »

Hi all Again!!!

the last post is so long and is difficult to reading.
so...the summary would be :

When i have nested View...how should i  manage the Mediators? and where should i register these!?

Thanks!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: July 31, 2008, 04:44:58 »

Sounds like you have a deferred instantiation problem. Search these forums for "deferred instantiation" and you'll find a lot of answers.

-=Cliff>
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #3 on: August 05, 2008, 08:18:03 »

@yeremy

I highly recommend Cliff's posts in the following topic: http://forums.puremvc.org/index.php?topic=280.0 His code examples are a great help for solving the problems you are having. They have really helped me out.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: August 16, 2008, 04:15:36 »

Here's a link to the new FAQ entry for this issue:

http://puremvc.org/content/view/91/185/

-=Cliff>
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #5 on: August 17, 2008, 11:15:41 »

Cliff,

Thanks for making it into an FAQ entry! This will come in handy. But where do we find the entire FAQ on the site? I can't seem to find it anywhere.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: August 17, 2008, 11:44:05 »

Ah, yes. I'm building a set of FAQs but want to finish my comb of the forums before opening them up, but I just didn't want to send one more weary soul off searching on this one since it really is a frequent one. Look for a FAQ section on the main site header soon.

-=Cliff> 
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #7 on: August 17, 2008, 06:22:22 »

Sweet thanks Cliff! Then I'm very much looking forward to it! If you don't mind I'd like to offer my post on registering multiple instances of the same mediator and proxies for a component. I can touch it up a bit though. Either way very looking forward to the FAQ. The folks at my work will be sure to check it out as well. Thanks!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #8 on: August 18, 2008, 04:45:40 »

Certainly ro send it along. That's one of the topics for sure,  but I don't remember if I've covered it yet.

-=Cliff>
Logged
Pages: [1]
Print