commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [SCXML] Transition/Var question
Date Fri, 27 Feb 2009 11:49:18 GMT
On Fri, Feb 27, 2009 at 3:53 AM, Linda Erlenhov
<linda.erlenhov@gmail.com> wrote:
> Hello
> I have in my Transitions added "var" on the form:
>
>    <transition       cond="${cancelOutcome eq 'success'}" target="editExit">
>      <var            name="outcome"
>                      expr="cancel"/>
>    </transition>
>
> (This example is taken directly from the SCXML specification)
>
> In my statemachine (a version similar, but not derived from the
> AbstractStateMachine that is included) I have added an "onTransition"
> function in my listner that when I am on a transition should check if there
> is an "var" and in that case send it to XXXX.
>
> I´m having trouble fetching the "var". My thought is that that I should
> derive a new class from the transition class that includes the method
> "getVar" but I´ve looked through the API and I don´t understand how this
> method should be written. Can anybody help me?
>
<snip/>

This will be short since I'm on the road. One approach is to declare
the variable in the root context (<datamodel> child of <scxml>) so it
will be easier to introspect.

Along the lines of (note use of <assign> instead of <var> in <transition>):

<scxml ...>

    <datamodel>
        <data name="outcome"/>
    </datamodel>

....

    <state ...>
        <transition cond="${cancelOutcome eq 'success'}" target="editExit">
            <assign name="outcome" expr="cancel"/>
        </transition>
    </state>

</scxml>

followed by introspection like so:

    getEngine().getRootContext().get("outcome");

-Rahul


> Best Regards
> /Linda
>

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


Mime
View raw message