tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/436-loading-robotlegs-application-as-a-module-into-a-non-robotlegs-applicationRobotlegs: Discussion 2012-01-05T09:05:06Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-24T12:25:46Z2011-11-24T12:25:46ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>Hello,</p>
<p>I have an application which was developed using RL say RoboApp.
There is a need that this application needs to be loaded as a
module into some other Non-Robotlegs framework application say
ManualApp. I could load the RoboApp into ManualApp and the UI shows
up. But, for some reason, the control doesn't reach the
onRegister() method and no event listeners are being registered.
The application works well in stand-alone mode.</p>
<p>Here is how I am initializing the app</p>
<p>'<?xml version="1.0" encoding="utf-8"?> <mx:Canvas
xmlns:mx="<a href=
"http://www.adobe.com/2006/mxml">http://www.adobe.com/2006/mxml</a>"
width="400" height="300"</p>
<pre>
<code> xmlns:application="com.msi.ewlan.nuxi.wingstats.application.*"
xmlns:view="com.msi.ewlan.nuxi.wingstats.application.view.*" creationComplete="onCreationComplete(event)">
<!--fx:Declarations >
<application:StatsContext contextView="{this}" />
</fx:Declarations-->
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.events.ItemClickEvent;
import mx.events.ListEvent;
private var statsContext:StatsContext;
public function nodeData(val:String):void
{
Alert.show("Selected Node is : "+val);
statsContext.eventDispatcher.dispatchEvent(new Event("Test Event from Main App"));
}
public function onCreationComplete(evt:FlexEvent):void {
statsContext = new StatsContext(this);
}
]]>
</mx:Script>
<view:StatsGraphPanel id="graphPanel" width="100%" height="100%" /></code>
</pre>
<p></mx:Canvas>'</p>
<p>I have a StatsGraphMediator class with onRegister() method like
below</p>
<p>'override public function onRegister():void {</p>
<pre>
<code> addContextListener(TreeNodeSelChangeEvent.TREE_NODE_SEL_CHANGED, selectionChanged);</code>
</pre>
<p>}'</p>
<p>I have run the app in debug mode, and I don't see the control
coming to the onRegister method. To my understanding, the
onRegister() method gets called immediately after the respective
view is added to the display list. I see the view added in the UI,
but... ....?</p>
<p>Is there anything special we need to take care when we load RL
apps as modules into another app ?</p>
<p>Thanks,<br>
Ravi</p></div>kotharavitag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-25T08:14:46Z2011-11-25T08:15:36ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>Hello kotharavi,</p>
<p>if I'm not wrong, I think that you should add statsContext to
the stage too.</p>
<p>public function onCreationComplete(evt:FlexEvent):void {</p>
<pre>
<code>statsContext = new StatsContext(this);
addChild(statsContext);</code>
</pre>
<p>}</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-28T11:20:30Z2011-11-28T11:20:30ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>I don't thin so... the 'statsContext' is not a view component.
It's more of a declaration/initialization code. Am I missing
something else ??</p></div>kotharavitag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-28T12:09:32Z2011-11-28T12:09:32ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>Hi kotharavi,<br>
Another possible cause for your issue:<br>
You are instantiating the Context twice,<br>
within the declaration tag:<br>
<application:StatsContext contextView="{this}" /></p>
<p>and through actionscript:<br>
private var statsContext:StatsContext;<br>
public function onCreationComplete(evt:FlexEvent):void<br>
{</p>
<p>statsContext = new StatsContext(this);</p>
<p>}</p>
<p>If you instantiate the context through actionscript, you
don’t need the declaration tag and vice versa. See if that
solves your problem.</p>
<p>If not:<br>
Is your RoboApp a Flex Module? Is the Canvas component in your code
snippet a child of the RoboApp Module?<br>
Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-28T12:34:20Z2011-11-28T12:34:20ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>Hey, Thanks for your response. In my code, the MXML code to
instantiate 'statsContext' is commented out.</p>
<p>No, in my code the 'Canvas' would be added as child to another
application that is launching this app as module.</p>
<p>Do you think 'coz it's a Canvas and not a Application, it is
unable to register the mediators to the view ??</p></div>kotharavitag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-28T12:51:55Z2011-11-28T12:51:55ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>“No, in my code the 'Canvas' would be added as child to
another application that is launching this app as
module.”</p>
<p>Sorry, but I don’t understand :)<br>
The Canvas is added to ManualApp and ManualApp is loading it as a
Module??<br>
Help me here.</p>
<p>If that Canvas is the Module that you are loading in ManualApp,
why don’t you use the Module tag instead of Canvas?</p>
<p>Anyway, another possible cause could be the fact that you are
instantiating the context through actionscript on creationComplete.
Try to do it on preinitialize!</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/116466652011-11-28T13:47:22Z2011-11-28T13:47:22ZLoading Robotlegs application as a module into a NON-Robotlegs application<div><p>-Also, if you use ModuleLoader maybe you need to set
moduleLoader.applicationDomain=ApplicationDomain.currentDomain;<br>
if you didn’t do it already</p>
<p>-Could you add addEventListener(ContextEvent.STARTUP_COMPLETE,
onStartUpComplete); //dispatched by Context.startup() in your
StatsContext class and a trace statement inside a method called
onStartUpComplete and see if the context has been initialized and
the mappings occured?</p>
<p>-Do you have a Mediator for your context view(the Canvas)? If
so, is its onRegister() called?</p></div>Ondina D.F.