PureMVC Architects Lounge

Announcements and General Discussion => Fabrication => Topic started by: krange on June 01, 2009, 02:26:45



Title: questions about moduleAddress and parent access
Post by: krange on June 01, 2009, 02:26:45
Hi,

First of all great work on the fabrication utility. I have it setup in a few of my projects and it's been extremely useful. In one of my projects  we load in multiple modules, and those modules then load in other modules as well (see diagram below).

Shell --> Module A     --> Module C
                              --> Module D
                              --> Module E
                              --> Module F

       --> Module B      --> Module C
                              --> Module D

       ---> Module ....

I have two questions:

1. I have set it up so that currently the shell or module that is loading a module in passes it it's moduleAddress class and instance name. This way the module loading in can get direct access to the parent it was loaded from. Since a parent can be anything from the shell to a few different types of modules, I didn't see any other way of getting this information. Is this the correct way to go about this?

2. I've also noticed that the FlexModuleLoader instance isn't providing me with the modules moduleAddress information. It always seems to show up null. I can grab other information from the loader, but just not the moduleAddress. So if I need to go the other direction and send information into the specific module instance, I can't grab the information correctly. Any initial thoughts as to why this might be? Is there another way I should go about this? Attached is my code for loading the module ( commented out some that was extraneous )....

:
var loader : FlexModuleLoader = new FlexModuleLoader();

loader.url = moduleVO.moduleSwfUrl;
loader.id = moduleVO.id;
loader.router = applicationRouter;

if ( moduleVO.moduleGroup != null ) {
loader.moduleGroup = moduleVO.moduleGroup;
loader.defaultRoute  = moduleVO.moduleGroup;
} else {
loader.defaultRouteAddress = applicationAddress;
}

// Event listening code here...

// Save loader reference here...

loader.loadModule();

Thanks,
Kris



Title: Re: questions about moduleAddress and parent access
Post by: bir on June 25, 2009, 03:02:35
1) That is the same way I do it, passing a reference to the parent router and address as the body of an initModule notification sent to the loaded module.

2) I noticed the same issue with moduleAddress.  Instead I use: module.moduleFabricator.moduleAddress

:
var module:FlexModuleLoader = modulesContainer.getChildAt(event.oldIndex) as FlexModuleLoader;
routeNotification(ControllerConstants.LEAVE_MODULE, proxy.state, null, module.moduleFabricator.moduleAddress);