Loading Robotlegs application as a module into a NON-Robotlegs application

kotharavi's Avatar

kotharavi

24 Nov, 2011 12:25 PM

Hello,

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.

Here is how I am initializing the app

'<?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"

       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%" />

</mx:Canvas>'

I have a StatsGraphMediator class with onRegister() method like below

'override public function onRegister():void {

    addContextListener(TreeNodeSelChangeEvent.TREE_NODE_SEL_CHANGED, selectionChanged);

}'

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... ....?

Is there anything special we need to take care when we load RL apps as modules into another app ?

Thanks,
Ravi

  1. 1 Posted by krasimir on 25 Nov, 2011 08:14 AM

    krasimir's Avatar

    Hello kotharavi,

    if I'm not wrong, I think that you should add statsContext to the stage too.

    public function onCreationComplete(evt:FlexEvent):void {

    statsContext = new StatsContext(this);
    addChild(statsContext);
    

    }

  2. 2 Posted by kotharavi on 28 Nov, 2011 11:20 AM

    kotharavi's Avatar

    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 ??

  3. Support Staff 3 Posted by Ondina D.F. on 28 Nov, 2011 12:09 PM

    Ondina D.F.'s Avatar

    Hi kotharavi,
    Another possible cause for your issue:
    You are instantiating the Context twice,
    within the declaration tag:
    <application:StatsContext contextView="{this}" />

    and through actionscript:
    private var statsContext:StatsContext;
    public function onCreationComplete(evt:FlexEvent):void
    {

    statsContext = new StatsContext(this);

    }

    If you instantiate the context through actionscript, you don’t need the declaration tag and vice versa. See if that solves your problem.

    If not:
    Is your RoboApp a Flex Module? Is the Canvas component in your code snippet a child of the RoboApp Module?
    Ondina

  4. 4 Posted by kotharavi on 28 Nov, 2011 12:34 PM

    kotharavi's Avatar

    Hey, Thanks for your response. In my code, the MXML code to instantiate 'statsContext' is commented out.

    No, in my code the 'Canvas' would be added as child to another application that is launching this app as module.

    Do you think 'coz it's a Canvas and not a Application, it is unable to register the mediators to the view ??

  5. Support Staff 5 Posted by Ondina D.F. on 28 Nov, 2011 12:51 PM

    Ondina D.F.'s Avatar

    “No, in my code the 'Canvas' would be added as child to another application that is launching this app as module.”

    Sorry, but I don’t understand :)
    The Canvas is added to ManualApp and ManualApp is loading it as a Module??
    Help me here.

    If that Canvas is the Module that you are loading in ManualApp, why don’t you use the Module tag instead of Canvas?

    Anyway, another possible cause could be the fact that you are instantiating the context through actionscript on creationComplete. Try to do it on preinitialize!

    Ondina

  6. Support Staff 6 Posted by Ondina D.F. on 28 Nov, 2011 01:47 PM

    Ondina D.F.'s Avatar

    -Also, if you use ModuleLoader maybe you need to set moduleLoader.applicationDomain=ApplicationDomain.currentDomain;
    if you didn’t do it already

    -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?

    -Do you have a Mediator for your context view(the Canvas)? If so, is its onRegister() called?

  7. Ondina D.F. closed this discussion on 05 Jan, 2012 09:05 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac