tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/803-no-subjectRobotlegs: Discussion 2013-04-23T15:17:10Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/261893912013-04-02T18:08:16Z2013-04-02T18:09:08ZPopup support with Module<div><p>In <a href=
"http://knowledge.robotlegs.org/discussions/problems/743-mediators-not-being-created-for-subviews-when-createmediator-is-called-on-parent-view-being-added-as-a-popup">
Mediators not being created for subviews when createMediator() is
called on parent view being added as a popup</a>, I was asking
about making robot legs work with popups and I was showed to attach
the context to the SystemManager instead of the context. This
worked great for my applications.</p>
<p>Now I trying to roboticize legacy code that written as a module
instead of an application. I started by emulating my previous
project:<br></p>
<pre>
<code><fx:Declarations>
<my:Context id="myContext"/>
</fx:Declarations></code>
</pre>
<pre>
<code>// called from onCreationComplete()
private function initContext():void
{
var contextView:DisplayObjectContainer = systemManager.topLevelSystemManager as DisplayObjectContainer;
myContext.contextView = contextView;
}</code>
</pre>
which is attaching the context to the systemManager (to work with
popups)
<p>However, and I started seeing the following errors:</p>
<pre>
<code>commandMap [object CommandMap]
ReferenceError: Error #1065: Variable ICommandMap is not defined.
at flash.system::ApplicationDomain/getDefinition()
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/applyInjection()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:35]
at org.swiftsuspenders::Injector/injectInto()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/Injector.as:125]
at org.swiftsuspenders::Injector/instantiate()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/Injector.as:139]
at org.robotlegs.base::CommandMap/execute()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:172]
at org.robotlegs.base::CommandMap/routeEventToCommand()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:232]
at Function/<anonymous>()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/CommandMap.as:98]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.robotlegs.base::ContextBase/dispatchEvent()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/ContextBase.as:70]
at org.robotlegs.mvcs::Context/startup()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:151]
at com.crowncastle.levelMaintenance::LmpContext/startup()[C:\development\flexworkspaces\2013.1\flex\src\module_levelMaintenance\src\com\crowncastle\levelMaintenance\LmpContext.as:28]
at org.robotlegs.mvcs::Context/checkAutoStartup()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:306]
at org.robotlegs.mvcs::Context/set contextView()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:185]
at LevelMaintenanceApplet/initContext()[C:\development\flexworkspaces\2013.1\flex\src\module_levelMaintenance\src\LevelMaintenanceApplet.mxml:128]
at LevelMaintenanceApplet/onCreationComplete()[C:\development\flexworkspaces\2013.1\flex\src\module_levelMaintenance\src\LevelMaintenanceApplet.mxml:133]
at LevelMaintenanceApplet/___LevelMaintenanceApplet_AppletBase1_creationComplete()[C:\development\flexworkspaces\2013.1\flex\src\module_levelMaintenance\src\LevelMaintenanceApplet.mxml:8]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()</code>
</pre>
<pre>
<code>ReferenceError: Error #1065: Variable IInjector is not defined.
... same as above ...</code>
</pre>
<pre>
<code>ReferenceError: Error #1065: Variable IMediatorMap is not defined.
... same as above ...</code>
</pre>
<p>I can make it work (with out popup support) if I change the
context to this:<br></p>
<pre>
<code><fx:Declarations>
<my:Context id="myContext" contextView="{this}" />
</fx:Declarations></code>
</pre>
which is attaching the context to the module.
<p>I am trying to add robot legs to the module, not necessarily the
application. There is only one module, but re-writing it as an
application isn't something I would like to do.</p>
<p>Is there anyway I can have things work with the module and
popups?</p></div>phillip.green.iitag:robotlegs.tenderapp.com,2009-10-18:Comment/261893912013-04-03T14:32:13Z2013-04-03T14:32:13ZPopup support with Module<div><p>Hey Phillip,</p>
<p>It is possible to load modules inside a popup in rl1, but
it’s a much more painful process (especially when it comes to
garbage collection) than in rl2.<br>
Too bad, you can’t or don’t want to use rl2 :)</p>
<p>Anyway, try this:<br>
View:</p>
<pre>
<code>protected var context:ApplicationContext;
//handler for mx.events.FlexEvent.PREINITIALIZE
protected function preinitializeHandler(event:FlexEvent):void
{
var contextView:DisplayObjectContainer = systemManager.topLevelSystemManager as DisplayObjectContainer;
context = new ApplicationContext(contextView);
}</code>
</pre>
<p>Config:<br></p>
<pre>
<code>public function ApplicationContext(contextView:DisplayObjectContainer = null, autoStartup:Boolean = true)
{
super(contextView, true);
}</code>
</pre>
<p>And tell me if it works for you.</p>
<p>I suppose you’re using the Modular utility, right?</p>
<p>Regarding the errors, it’s hard to tell what they mean.
Maybe it has to do with the way you pass the ApplicationDomain to
the module.</p>
<p>Can you post the code for your main context, and that of the
module, and also the part where you set parentInjector in your
module.</p>
<p>If you can, it would be even better to attach the app (as zip),
or a simple example that reproduces the issue. It might be easier
to find the culprit(s).</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/261893912013-04-03T14:57:02Z2013-04-03T14:57:02ZPopup support with Module<div><p>If you want it in your declaration tag:</p>
<pre>
<code><context:ApplicationContext contextView="{SystemManager.getSWFRoot(this) as DisplayObjectContainer}"/></code>
</pre>
<p>But this in conjuction with the modular utility, mappings get
overwritten and you get some warnings....<br>
I prefer to instantiate the context through actionscript.</p></div>Ondina D.F.