commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <>
Subject Re: [scxml] datamodel, custom actions and digester
Date Wed, 11 Aug 2010 04:29:52 GMT
On Tue, Aug 10, 2010 at 7:11 PM, Abigail Gertner <> wrote:
> Hi --
> I have a couple of questions about using commons SCXML.
> I am trying to use the datamodel within a state as a kind of template,
> so when I enter the state, I will set some values within the datamodel
> and then execute some code with the resulting data.
> I was trying to use an <assign> statement within the state's <onentry>
> tag and then use the onEntry() method of a Listener to do the additional
> processing of the data, but I found that the listener did not get the
> values that had been set by the assign statement as part of the
> datamodel associated with its target node. It only gets the original
> datamodel when I call target.getDatamodel() - not the version with the
> updated values. Is this correct?

The getDatamodel() call returns an oacs.model.Datamodel object
(anything belonging to the model package is not part of an executing
state machine, rather its part of the state machine description itself
i.e. the "model" on which the executor operates).

So yes, the above behavior you note is certainly as expected. Note
that the above is useful in some scenarios, such as "reset" type
scenarios where one may want to restore the datamodel to its original

The way to obtain the live values of the datamodel is to use the
expression evaluator, see interfaces mentioned here:

> So, I think I need to use a custom action to do this. I think I have
> figured out how to implement the custom action. My problem now is that
> (for unrelated reasons) I am using a dispatcher obtained from
> SCXMLParser.newInstance() to parse the scxml document and I don't know
> how to include the custom action when I am doing it this way. In the
> documentation for custom actions, it says that "the digester rules can
> be added by directly by obtaining a Digester instance with the "default"
> SCXML rules using the newInstance() methods and further directly adding
> the necessary rules using the digester API." Can someone give me a bit
> more information or an example on how to accomplish this?

You'll need to be familiar with Digester, which is what the above
method returns (an instance thereof):

The idea is to register the custom action related digester rule(s)
that inject the backing action classes in the SCXML object model (for
example, the digester paths will likely be "!*/onentry/foo",
"!*/onexit/foo", "!*/transition/foo", "!*/if/foo" where "foo" is the
custom action).

Might be worthwhile revisiting the need for using
SCXMLParser#newInstance() rather than the static parse methods.

> Alternatively, if there is a way to do what I am trying to do (assign
> some values to the data and then pass that data to a listener) without a
> custom action I would like to know that too.

Some data, such as that available in the root context, may be accessed
directly if the listener has a handle to the root context.


> Thanks for your help

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message