配合:无法设置属性模型
问题描述:
我有一个模块的应用程序。每个模块都是完全独立的。他们之间没有共享事件或其他任何事情。在每个模块中都有一个DataGrid和一个ContextMenu。所选数据的详细信息在一个弹出窗口中打开。像往常一样,模块由loalEventMap和presentationModel控制。配合:无法设置属性模型
如果我立即关闭一个弹出窗口并再次打开,所有工作正常。但是,如果我改变,在弹出的一些数据,将其关闭,卸载我的模块,再加载,然后再次打开弹出,伴侣引发以下错误:
- 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::[email protected] 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]
我的实现:
打开弹出窗口:
inputMask = new CDBInputMask();
PopUpManager.addPopUp(inputMask,this,true);
关闭弹出窗口:
PopUpManager.removePopUp(inputMask);
inputMask = null; 注射器:
<Injectors target="{CDBInputMask}" debug="true" dispatcherType="global" >
在伴侣,论坛,我发现有一个类似的线程,但不完全相同,问题。这里的主持人意味着它看起来像试图在模块中两次实例化一个类。在我的情况下,PopUpManager是一个单例类。所以它看起来像是同样的问题。第一次通过所有的工作正常,第二次通过它崩溃,所有,因为该类已被注入。
我试图使用跟踪调试器来查看如何清除弹出或清除模块。但我还没有找到解决方案。如果您需要更多代码,我会发布它。
在此先感谢。 Frank
答
听起来像ApplicationDomain问题。
可能发生的情况是类定义在不同的安全域上被多次加载。尽管这些物体看起来像是同一类,但这会造成铸造问题。就Flash运行时而言,它们不是同一类型,除非它们位于同一个安全域中。
要解决此给装载机使用主应用程序的安全域上下文(假设你使用Loader类来加载模块):
var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loader.loader(request, context);