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] JEXL, object setter does not work ?
Date Thu, 17 Jul 2008 17:18:57 GMT
On Wed, Jul 16, 2008 at 3:12 PM, Daniel Schwager
<Daniel.Schwager@dtnet.de> wrote:
> Hi Rahul,
>
> i created a statemachine with an JEXL context. In
> my XML-description, I do the following:
>
>        ....
>        <onentry>
>                <log    expr="'job said: ' + job.stateInformation" />
>                <assign name="job.stateInformation" expr="'SET MY
> JOB'"/>
>        </onentry>
>        ....
>
> The context has injected an object Bean-Job with the property
> stateInformation.
> The setter/getter are available:
>                StateMachineJob smJob = new StateMachineJob();
>                smJob.setStateInformation ("OK - DONE");
>                sm.setVariable("job", smJob);
>
> If i run the automat, i got:
>        INFO - null: job said: OK - DONE
>        WARN - UNDEFINED_VARIABLE (job.stateInformation = null):
>
> So, I'm not able to set my job.setStateInformation() ...
> If I try the same with a normal "String" variable instead of an object
> with setter/getter,
> the assignment works fine.
>
> Did I miss something ?
>
<snip/>

Usage for <assign> is really limited to the variants described at the
bottom of this page:

  http://commons.apache.org/scxml/guide/datamodel.html

It is not intelligent enough to do the kind of property assignment
you're attempting here. It will take the "name" to be the variable
name in its entirety and not attempt to parse it in any fashion.

When using JEXL, I'd recommend implementing a <jexl:script> custom
action and solving a broad suite of such issues. Using the
ScriptFactory [1] API in JEXL 1.1 that should be fairly trivial.

Ofcourse, JEXL allows you to call the setter directly i.e.
job.setStateInformation('SOME INFO') as the expression.

-Rahul

[1] http://commons.apache.org/jexl/apidocs-1.1/org/apache/commons/jexl/ScriptFactory.html


> regards
> Danny
>
>

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


Mime
View raw message