Issues with resources injection in multi-module application with pop ups

Description

We are developing application with multiple Flex modules that are loaded when they are required for user. Each module has its own swiz configuration, swiz and Bean.mxml. Example of the configuration:

<s:Application ...>
...
<fxeclarations>
<swiz:SwizConfig id="swizConfig"
strict="true"
defaultFaultHandler="genericFault"
eventPackages="ua.org.patientregistry.mainview.event.*"
viewPackages="ua.org.patientregistry.mainview.view.,ua.org.patientregistry.commons.components."/>
<swiz:Swiz id="swiz" beanProviders="{[Bean]}" config="{swizConfig}"/>
</fxeclarations>
...
</s:Application>

<mx:Module ...>
...
<fxeclarations>
<swiz:SwizConfig id="swizConfig"
strict="true"
defaultFaultHandler="genericFault"
eventPackages="ua.org.patientregistry.usersandrolesview.event.*"
viewPackages="ua.org.patientregistry.usersandrolesview.view.*"/>
<swiz:Swiz id="swiz" beanProviders="{[Bean]}" config="{swizConfig}"/>
</fxeclarations>
...
</mx:Module>

Also each module has set of dialogs that are used for getting an user input. Those dialogs are MXML files in viewPackages of corresponding dialogs and the dialogs have resource injection annotations, for example:

[Inject]
[Bindable]
public var model:IUsersAndRolesDialogPresentationModel;

So the problem is: Swiz does not inject resources to a dialog if the dialog is shown with using PopUpManager. But the injection works perfectly if we create dialog from application, not from loaded module.

After analyzing of Swiz sources it was found that the following condition in method org.swizframework.core.BeanFactory.isPotentialInjectionTarget is always true for dialogs that are created from loaded module:

if( !swiz.domain.hasDefinition( className )

It's because only parent Swiz receives Event.ADDED_TO_STAGE events but domain of application knows nothing about classes of modules.

We tried to set others setUp and tearDown events in modules:

<mx:Module ...>
...
<fxeclarations>
<swiz:SwizConfig id="swizConfig"
strict="true"
defaultFaultHandler="genericFault"
eventPackages="ua.org.patientregistry.usersandrolesview.event.*"
viewPackages="ua.org.patientregistry.usersandrolesview.view.*"
setUpEventType="{Event.ADDED}"
tearDownEventType="{Event.REMOVED}"/>
<swiz:Swiz id="swiz" beanProviders="{[Bean]}" config="{swizConfig}"/>
</fxeclarations>
...
</mx:Module>

After that Swiz of the module began receiving event and we could avoid the issue with domain that are described above. But unfortunately we run into another issue: Swiz cannot construct bean for a dialog:

ReferenceError: Error #1065: Variable UserAndRolesDialogView is not defined.
at flash.system::ApplicationDomain/getDefinition()
at org.swizframework.reflection::TypeDescriptor/fromXML()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\reflection\TypeDescriptor.as:179]
at org.swizframework.reflection::TypeCache$/getTypeDescriptor()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\reflection\TypeCache.as:55]
at org.swizframework.core::BeanFactory$/constructBean()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\core\BeanFactory.as:423]
at org.swizframework.core::SwizManager$/setUp()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\core\SwizManager.as:63]
at org.swizframework.core::BeanFactory/setUpEventHandler()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\core\BeanFactory.as:379]
at org.swizframework.core::BeanFactory/setUpEventHandlerSysMgr()[C:\MyDocs\Development\Swiz\swiz-framework\src\org\swizframework\core\BeanFactory.as:392]
at flash.display:isplayObjectContainer/addChildAt()

It looks like because the dialog are not added to module by PopUpManager, so the code in the end of method org.swizframework.core.SwizManager.setUp are always executed:

// this is stupid, if we got here, no swiz had a dispatcher
// containing the view (like, it's a freaking popup). make the first swiz do it
var rootSwiz:ISwiz = swizzes[ 0 ];
wiredViews.push( uid );
rootSwiz.beanFactory.setUpBean( BeanFactory.constructBean( dObj, null, swiz.domain ) );

and domain from parent swiz is used. But again - domain of application swiz doesn't see classes of a module.

So from all facts are described above I can conclude that there is a bug in Swiz. But if it was just my fault and I used incorrect Swiz configuration, I would appreciate your corrections.

Environment

None

Status

Assignee

ChrisC

Reporter

Bogdan Prishedko

Labels

None

Affects versions

Priority

Major
Configure