I have an application with modules. Every Module is completely self-contained. There are no shared events or anything else between them. In each modules there is a DataGrid and with a ContextMenu. The details of selected data open in a popup window. The modules are controlled by an loalEventMap and a presentationModel as usual.
If I closed a popup immediately and open it again, all works fine. But if I change some data in the popup, close it, unload my module, load the module again, and open the popup again, Mate throws the following error:
- ERROR: Unable to set property model on CDBInputMask because is not type CDBPresentationModel. Provided value was of type CDBPresentationModel
- TARGET: CDBInputMask
- TARGET KEY: model
- TAG: PropertyInjector
- FILE: CDBLocalEventMap
- STACK TRACE: TypeError: Error #1034: Type Coercion failed: cannot convert com.mycomp.myMod.ui.presenters::CDBPresentationModel@5d13cf1 to com.mycomp.myMod.ui.presenters.CDBPresentationModel. at com.asfusion.mate.core::Binder/bind()[/Users/Nahuel 1/Documents/Flex Builder 3/Mate_trunk/src/com/asfusion/mate/core/Binder.as:90] at com.asfusion.mate.actions::PropertyInjector/run()[/Users/Nahuel 1/Documents/Flex Builder 3/Mate_trunk/src/com/asfusion/mate/actions/PropertyInjector.as:205]
My implementation:
open Popup:
inputMask = new CDBInputMask();
PopUpManager.addPopUp(inputMask,this,true);
close Popup:
PopUpManager.removePopUp(inputMask);
inputMask = null; Injector:
<Injectors target="{CDBInputMask}" debug="true" dispatcherType="global" >
In the Mate-Forum I found a thread with a similar, but not quite identical, problem. Here the moderator meant that it looks like it's trying to instantiate a class twice in a module. In my case, the PopUpManager is a singleton class. So it looks like the same problem. First time through all works fine, Second time through it crashes, all because the class is already injected.
I tried to use a debugger with tracing to see how I could clear the popup or clear the module. But I have not found a solution. If you need any further code, I'll post it.
Thanks in advance. Frank
Sounds like ApplicationDomain issues.
What is likely happening is that the class definitions are being loaded multiple times on different security domains. This will cause the casting issues despite the objects looking like they are of the same class. As far as the Flash runtime is concerned they are not the same type unless they are on the same security domain.
To resolve this give the loader a context with your main application's security domain used (assuming you are using the Loader class to load your modules):