3 Replies Latest reply: May 10, 2011 8:29 AM by Alex Uhlmann RSS

    Cairngorm 3 Module and Parsley Context initialization problem.

    purusothamyb Community Member

      Hi,

       

         I am using parsley 2.2, cairngorm 3 module library. When the module is loaded the parsley context is not getting initialized at that time and returing null for the objects managed by the parsley container.

       

      <fx:Script>

      <![CDATA[

      import mx.events.FlexEvent;

       

      import org.spicefactory.parsley.flex.modules.FlexModuleSupport;

      import org.spicefactory.parsley.flex.tag.builder.ContextBuilderTag;

       

      [Bindable][Inject]public var faultMgtContainerPM:NMSFaultMgtContainerPM;

       

      public function get contextBuilder() : ContextBuilderTag

      {

      return contextBuilderTag;

      }

      ]]>

      </fx:Script>

       

      <fx:Declarations>

       

      <spicefactory:ContextBuilder id="contextBuilderTag" config="{ NMSFaultMgtModuleContext }" />

      <spicefactory:Configure />

      <s:Consumer id="notification" destination="sessionlog-notification-bus"

      fault="faultMgtContainerPM.notification_faultHandler(event)"

      message="faultMgtContainerPM.notification_messageHandler(event)"/>

      </fx:Declarations>

       

      In the above code the Inject of NMSFaultMgtContainerPM class doesn't work and returing null when accessed in the creationComplete event of the app.

       

      By the way the context file contains the NMSFaultMgtContainerPM class entry.

       

      Please let me know if I am missing any thing.

       

      Regards,

      Purushotham

        • 1. Re: Cairngorm 3 Module and Parsley Context initialization problem.
          Nicolas Yuen Adobe Employee

          Hi,

           

          Please have a look at the [Init] metadata from the Parsley configuration : http://www.spicefactory.org/parsley/docs/2.1/manual/lifecycle.php#methods

           

          If you want the Parsley Container to invoke methods on your object when it is created or when it is destroyed, you can add the [Init] or [Destroy] metadata tags to the corresponding methods:

           

           

          [Init] public function init () : void
          {    
               [...]
          }

          [Destroy] public function dispose () : void
          {    
               [...]
          }

          The methods marked with [Init] get invoked after the object has been instantiated and all injections have been processed.

          The methods marked with [Destroy] get invoked after the Context instance they belong to has been destroyed with Context.destroy() or when the object was removed from the Context. See 6.3 Object Lifecycle Methods for details.

           

          For Flex Components declared in regular MXML files and wired to the Context as described in 7 Dynamic View Wiring the lifecycle is different: For those objects the methods get invoked whenever the object is added to or removed from the stage respectively. Of course the [Destroy] method additionally gets invoked if the Context the object was wired to was destroyed.

           

          Let me know if this works for you

          • 2. Re: Cairngorm 3 Module and Parsley Context initialization problem.
            purusothamyb Community Member

            Hi,

             

                Thanks for your quick reply.

             

            your solution didn't work out for me.

             

             

            Let me explain my problem in detailed.

             

            I have a PM class with variable dataProvider.This PM Class is managed by the parsley container.

            I have an UI class which injects this PM and the dataprovider of the PM class is binded to the UI object's dataprovider (ex: DataGrid).

             

            When I launch the application the DataGrid is displayed with no content. And when I try to print the injected PM instance in the creationComplete event of

            the DataGrid. It says null.

             

            Please help me on this.

             

            Regards,

            Purushotham

            • 3. Re: Cairngorm 3 Module and Parsley Context initialization problem.
              Alex Uhlmann Community Member

              Looks like your view isn't wired to Parsley. Check for i.e. a Configure tag (see Parsley developer guide)