0

The architecture is based on the use of the following frameworks: Flex, Cairngorm and Parsley.

I use a dispatcher with an event "AdicionarItemVendaMercadoriaEvent" within a popuppanel: PopupPanel.

I capture the event with [MessageHandler] within the FormPM.as injected into Form.mxml. Within Form.mxml, I have a mx: TabNavigator and each tab is within one s: NavigatorContent.

It turns out that when there is more than one open tab mx: TabNavigator the dispatched event is captured in all Form of all tabs.

Normal operation was to capture the only event of the tab where the PopupPanel was dispatched, not all tabs.

Please, any suggestions for solving this problem?

I appreciate the help.

ketan
  • 19,129
  • 42
  • 60
  • 98
  • 1
    You could save the tab reference in the message and check it in the handler. – dvdgsng Jun 13 '13 at 20:11
  • Yes do the above. Another slightly more optimal approach would be to use a different event `type` (ie: use `AdicionarItemVendaMercadoriaEvent.TAB_ONE`, `AdicionarItemVendaMercadoriaEvent.TAB_TWO`, etc.) for each tab. This way, when you dispatch the message, only one [MessageHandler] would get invoked, instead of invoking them all. – Sunil D. Jun 13 '13 at 23:40
  • The tabs are generated dynamically when the User clicks a button to add. Thus, it would be ideal to generate an event differently for each flap. @dvdgsng – user2478505 Jun 14 '13 at 11:56
  • The tabs are generated dynamically when the User clicks a button to add. Thus, it would be ideal to generate an event differently for each flap. @SunilD. – user2478505 Jun 14 '13 at 11:57

1 Answers1

0

How about using straight forward function callbacks?

When you create your PopUpPanel, pass in a function callback that you want to be executed when the popup is closed. Rather than using an event, you'd simply call the function. i.e.

Inside FormPM:

public function showPopup():void
{
    var popup:PopUpPanel = new PopUpPanel();
    popup.onCompletion = handleResult;
    PopUpManager.addPopUp(popup, ...);
}

private function handleResult(someData:*):void 
{
   // My popup has completed.. what do I want to do with the result.
}

You might want to consider the Spicelib 3.0 command framework and have a command to popup your panel and then add the error/success callbacks to that: http://www.spicefactory.org/parsley/docs/3.0/manual/?page=commands&section=intro

dannrob
  • 1,061
  • 9
  • 10
  • The handleResult is private? Would be captured in PopupPanel own? But I want to capture the event with their properties in FormPM.as, not PopupPanel. I'll try dispacher an Event with its properties in PopupPanel and capture a [CommandResult] used parsley. @dannrob – user2478505 Jun 14 '13 at 12:11
  • Hey, I've updated my answer, the point is that you'd pass your function into the PopupPanel so that the form that initiated the popup get the result and no one else. Frameworks are great, but sometimes over complicate what is really just standard function calls! – dannrob Jun 14 '13 at 16:55