Skip navigation
Currently Being Moderated

Cairngorm 3 Module and Parsley Context initialization problem.

May 10, 2011 1:26 AM

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

 
Replies
  • Currently Being Moderated
    May 10, 2011 2:09 AM   in reply to purusothamyb

    Hi,

     

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

     

    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

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2011 8:29 AM   in reply to purusothamyb

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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points