Mapping event with second type to command is not working

olegkon's Avatar

olegkon

01 Aug, 2016 03:13 PM

Hi,

I am doing enhancements to existing Robotlegs2 web app.
So my popup dispatches event of type1, which main app listens to,
so on that event Command calls Service, which in calls remote Java service,
which calls DB via Spring JDBC template, and returns me status string
(success or some Error).
Now I am adding a second type - type2, and the rest is similar (except I pass extra params to Stored Proc 2).

For some reason I see Event dispatched, but Commend for type2 is NOT getting executed.
Is there a limitation that I can't do:
moduleCommandMap.mapEvent(ChangePasswordEvent.type1, ChangePasswordRequestCommand, ChangePasswordEvent);
moduleCommandMap.mapEvent(ChangePasswordEvent.type2, ChangePasswordRequestCommand, ChangePasswordEvent);

What else might be missing or wrong?

I am fairly new to Robotlegs2.
Please help.

TIA,
Oleg.

  1. Support Staff 1 Posted by Ondina D.F. on 09 Aug, 2016 09:26 AM

    Ondina D.F.'s Avatar

    Hi Oleg,
    Sorry for the late response. I haven't received any notifications about your message, and since you've marked the discussion as private, I didn't see it on the forum's web page either, until now. Is there any reason you want this discussion to be private, or it just happened by accident?
    To your question:
    There is no limitation on the number of events or event types mapped to a command.
    In robotlegs 2 the mapping should look like this:

    public class SomeConfig implements IConfig
    {
        [Inject]
        public var commandMap:IEventCommandMap;
        public function configure():void
        {
            commandMap.map(SomeEvent.SOME_TYPE, SomeEvent).toCommand(SomeCommand);
            commandMap.map(SomeEvent.ANOTHER_TYPE, SomeEvent).toCommand(SomeCommand);
            commandMap.map(AnotherEvent. OTHER_TYPE, SomeEvent).toCommand(AnotherCommand);
        }
    }
    

    What is moduleCommandMap in your example? Is it just the name of the variable of type IEventCommandMap?

    Now I am adding a second type - type2, and the rest is similar (except I pass extra params to Stored Proc 2).

    If your event is carrying a payload ( the params ?), you need to inject the event into your command, so that you can access the params there:

    [Inject]
    public var event: ChangePasswordEvent;
    public function execute():void
    {
        doSomethingWith(event.payload);
    }
    

    If that doesn't solve your problem, please show the code (or an example) where your command is trying to access the event's payload.
    Ondina

  2. 2 Posted by olegkon on 09 Aug, 2016 11:43 AM

    olegkon's Avatar

    Hi,
    I was able to resolve it:in second case user is entering there through deep linking,(parent of popup is different)so I needed to use different context Thank you for your help, Oleg.

  3. Support Staff 3 Posted by Ondina D.F. on 10 Aug, 2016 10:41 AM

    Ondina D.F.'s Avatar

    No problem!

  4. Ondina D.F. closed this discussion on 10 Aug, 2016 10:41 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac