Skip to main content
Participant
May 10, 2011
Question

Cairngorm 3 Module and Parsley Context initialization problem.

  • May 10, 2011
  • 1 reply
  • 3460 views

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

This topic has been closed for replies.

1 reply

Adobe Employee
May 10, 2011

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

Participant
May 10, 2011

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

Participating Frequently
May 10, 2011

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