Problem in dispatching event from DynamicCommand(Parsley)
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)
