Skip to main content
Participant
March 22, 2010
Question

Problem in dispatching event from DynamicCommand(Parsley)

  • March 22, 2010
  • 1 reply
  • 1494 views

Hi,

I am dispacthing event from the result of my command(Dynamic). This event is handled on view using parsley MessageHandler. This event is not received on view.

I have debug the code of my command and found that the destroy method of command is called before command result. So I think when command is removed from context then it would not be able to dispatch event.

Please help here to find the solution of this problem.
I am sharing my code below for reference


I am defining the command in config like this:-

<DynamicCommand type="{GetAccountDetailsCommand}" messageType="{AccountEvent}" selector="{AccountEvent.GET_ACCOUNT_DETAILS}"/>

and my command execute method is like this:-

[Command(selector="get_account_details")]
public function execute( event : AccountEvent) : AsyncToken
{
_accountDetailsModel = AccountDetailsModel(event.model);
return _service.getAccountDetails(event.serial, new ServiceResponder(result, fault));
}

and I am dispatching event in command result :-

public function result(event:ResultEvent):void

if(event.result)
{

var accountEvent:AccountEvent = new  AccountEvent(AccountEvent.GET_ACCOUNT_DETAILS_SUCCESS);
accountEvent.model = _accountDetailsModel;
dispatchEvent(accountEvent);
}

}

This event is handled on view like this :-

[MessageHandler(selector="get_account_details_success")]
public function getAccountDetailsSuccess(event:AccountEvent):void
{
if(event.model == accountDetailsModel)
{
updateWorkshopVisibility();

accountDetailsModel.loadAllAccountData(this.serial);
}
}

But this method never gets called on dispatching event from command result.

I have also mentioned event type and managed event in command as given below :-

[Event(name="get_account_details_success", type="com.uis.accounts.events.AccountEvent")]

[ManagedEvents("get_account_details_success")]



(Thanks in advance)

This topic has been closed for replies.

1 reply

Participating Frequently
March 22, 2010

Hi there,

instead of dispatching a another global event in a result or error handler of a Command, it might be easier to use the CommandResult, CommandError and CommandStatus object definitions. Check out the Parsley developer guide for more information. The Insync samples of in Cairngorm trunk/samples show other real world  examples of this.  Also, make sure that the view contains a Configure tag and is therefore registered with Parsley.