You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Tony Seebregts <to...@iveri.com> on 2008/04/29 15:43:11 UTC

[SCXML] _eventdata not included in collection events ?

Hi,

I'm trying to pass information from a class that extends Action via a
TriggerEvent payload but in the SCXML script the _eventdata value for
the associated event transition seems to be null.

Any ideas ?

The payload works fine if I call triggerEvent but not if I just add the
event to the events Collection and I can't figure out why (for various
reasons triggerEvent doesn't work in the scenario).

The relevant code is:

public void execute(EventDispatcher dispatcher,
                    ErrorReporter   reporter,
                    SCInstance      instance,
                    Log             log,
                    Collection      events) throws
ModelException,SCXMLExpressionException
       { Evaluator evaluator = instance.getEvaluator();
         Context   context   = instance.getContext  (getParentState());
         String    uidx      = null;
         String    pinx      = null;
         int       serviceID;
         User      user;

         try
            { if (uid != null)
                 uidx = (String) evaluator.eval(context,uid);

              if (pin != null)
                 pinx = (String) evaluator.eval(context,pin);

              if ((user = login(uidx,pinx)) == null)
                 { events.add(INVALID);
                   return;
                 }

              events.add(new  TriggerEvent("ok",
TriggerEvent.SIGNAL_EVENT, user));
                       return;
            }
         catch(Throwable x)
            { log.error("Error logging in: " + x.toString());
            }

         instance.getExecutor().triggerEvent(ERROR);
       }

regards

Tony Seebregts

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [SCXML] _eventdata not included in collection events ?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/30/08, Tony Seebregts <to...@iveri.com> wrote:
> Ah, of course ... thanks Rahul !
>
>  This exposes a problem with the Javascript evaluator though. The
>  Javascript engine (both JDK and JSR223) isn't able to apply the []
>  operator to a HashMap because its a Java object rather than a Javascript
>  object (using _eventdatamap.get('event.name') works fine).
>
>  Will file a bug...
>
<snip/>

Makes sense, will comment on SCXML-71.

-Rahul


>  regards
>
>
>  Tony
>
>
>
>  >> Hi,
>  >>
>  >>  I'm trying to pass information from a class that extends Action via a
>  >>  TriggerEvent payload but in the SCXML script the _eventdata value for
>  >>  the associated event transition seems to be null.
>  >>
>  >>  Any ideas ?
>  >>
>  >>  The payload works fine if I call triggerEvent but not if I just add the
>  >>  event to the events Collection and I can't figure out why (for various
>  >>  reasons triggerEvent doesn't work in the scenario).
>  >>
>  > <snip/>
>  >
>  > Yup, you shouldn't use triggerEvent here.
>  >
>  > The way derived events are handled is to process all of them in a
>  > microstep. Since there may be more than one event, _eventdata is
>  > ambigous, and _eventdatamap['event.name'] should be used instead for
>  > derived events.
>  >
>  > For example, see the eventdata_* test case documents in the JUnit test
>  > suite ... few of them are here:
>  >
>  > http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/
>  >
>  > -Rahul
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [SCXML] _eventdata not included in collection events ?

Posted by Tony Seebregts <to...@iveri.com>.
Ah, of course ... thanks Rahul !

This exposes a problem with the Javascript evaluator though. The
Javascript engine (both JDK and JSR223) isn't able to apply the []
operator to a HashMap because its a Java object rather than a Javascript
object (using _eventdatamap.get('event.name') works fine).

Will file a bug...

regards

Tony


>> Hi,
>>
>>  I'm trying to pass information from a class that extends Action via a
>>  TriggerEvent payload but in the SCXML script the _eventdata value for
>>  the associated event transition seems to be null.
>>
>>  Any ideas ?
>>
>>  The payload works fine if I call triggerEvent but not if I just add the
>>  event to the events Collection and I can't figure out why (for various
>>  reasons triggerEvent doesn't work in the scenario).
>>
> <snip/>
> 
> Yup, you shouldn't use triggerEvent here.
> 
> The way derived events are handled is to process all of them in a
> microstep. Since there may be more than one event, _eventdata is
> ambigous, and _eventdatamap['event.name'] should be used instead for
> derived events.
> 
> For example, see the eventdata_* test case documents in the JUnit test
> suite ... few of them are here:
> 
> http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/
> 
> -Rahul


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [SCXML] _eventdata not included in collection events ?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/29/08, Tony Seebregts <to...@iveri.com> wrote:
> Hi,
>
>  I'm trying to pass information from a class that extends Action via a
>  TriggerEvent payload but in the SCXML script the _eventdata value for
>  the associated event transition seems to be null.
>
>  Any ideas ?
>
>  The payload works fine if I call triggerEvent but not if I just add the
>  event to the events Collection and I can't figure out why (for various
>  reasons triggerEvent doesn't work in the scenario).
>
<snip/>

Yup, you shouldn't use triggerEvent here.

The way derived events are handled is to process all of them in a
microstep. Since there may be more than one event, _eventdata is
ambigous, and _eventdatamap['event.name'] should be used instead for
derived events.

For example, see the eventdata_* test case documents in the JUnit test
suite ... few of them are here:

http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/

-Rahul


>  The relevant code is:
>
>  public void execute(EventDispatcher dispatcher,
>                     ErrorReporter   reporter,
>                     SCInstance      instance,
>                     Log             log,
>                     Collection      events) throws
>  ModelException,SCXMLExpressionException
>        { Evaluator evaluator = instance.getEvaluator();
>          Context   context   = instance.getContext  (getParentState());
>          String    uidx      = null;
>          String    pinx      = null;
>          int       serviceID;
>          User      user;
>
>          try
>             { if (uid != null)
>                  uidx = (String) evaluator.eval(context,uid);
>
>               if (pin != null)
>                  pinx = (String) evaluator.eval(context,pin);
>
>               if ((user = login(uidx,pinx)) == null)
>                  { events.add(INVALID);
>                    return;
>                  }
>
>               events.add(new  TriggerEvent("ok",
>  TriggerEvent.SIGNAL_EVENT, user));
>                        return;
>             }
>          catch(Throwable x)
>             { log.error("Error logging in: " + x.toString());
>             }
>
>          instance.getExecutor().triggerEvent(ERROR);
>        }
>
>  regards
>
>  Tony Seebregts
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org