You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dario D <da...@gmail.com> on 2011/05/09 22:19:01 UTC
[scxml] Creating ad-hoc arrays in JEXL expressions
Hello,
I am trying to create an ad-hoc array in my workflow and provide it to a
custom action:
<state id="fetchCustomerData">
<onentry>
<log expr="'Customer - Fetching data'"/>
<al:fetchTableData select="['col1', 'col2']" />
</onentry>
</state>
In the custom action, I am evaluating this string through JEXL Evaluator:
public void execute(EventDispatcher eventDispatcher, ErrorReporter
errorReporter, SCInstance scInstance, Log log, Collection collection) throws
ModelException, SCXMLExpressionException {
log.info(scInstance.getEvaluator().eval(scInstance.getRootContext(),
this.getSelect()));
}
This throws an error:
WARNING: EXPRESSION_ERROR (eval('['col1', 'col2']'):Encountered "[" at line
1, column 1.
Was expecting one of:
<EOF>
<INTEGER_LITERAL> ...
<FLOAT_LITERAL> ...
"{" ...
"empty" ...
"(" ...
"size" ...
"-" ...
"~" ...
"!" ...
"not" ...
"null" ...
"true" ...
"false" ...
";" ...
"if" ...
"while" ...
"foreach" ...
<IDENTIFIER> ...
<STRING_LITERAL> ...
):
Is creating arrays (or HashMaps, for that matter) even possible like this in
SCXML? I was following the guide at:
http://commons.apache.org/jexl/reference/syntax.html
The executor was created like this:
SCXMLExecutor exec = null;
exec = new SCXMLExecutor(new JexlEvaluator(), new
SimpleDispatcher(), new SimpleErrorReporter());
Context ctx = new JexlContext();
exec.setRootContext(ctx);
exec.setStateMachine(scxml);
exec.setSuperStep(true);
Thank you!
Re: [scxml] Creating ad-hoc arrays in JEXL expressions
Posted by Dario D <da...@gmail.com>.
Thanks a lot Rahul.
2011/5/10 Rahul Akolkar <ra...@gmail.com>
> On Mon, May 9, 2011 at 4:19 PM, Dario D <da...@gmail.com> wrote:
> > Hello,
> >
> > I am trying to create an ad-hoc array in my workflow and provide it to a
> > custom action:
> >
> > <state id="fetchCustomerData">
> > <onentry>
> > <log expr="'Customer - Fetching data'"/>
> > <al:fetchTableData select="['col1', 'col2']" />
> > </onentry>
> > </state>
> >
> > In the custom action, I am evaluating this string through JEXL Evaluator:
> >
> > public void execute(EventDispatcher eventDispatcher, ErrorReporter
> > errorReporter, SCInstance scInstance, Log log, Collection collection)
> throws
> > ModelException, SCXMLExpressionException {
> > log.info
> (scInstance.getEvaluator().eval(scInstance.getRootContext(),
> > this.getSelect()));
> > }
> >
> > This throws an error:
> >
> > WARNING: EXPRESSION_ERROR (eval('['col1', 'col2']'):Encountered "[" at
> line
> > 1, column 1.
> > Was expecting one of:
> > <EOF>
> > <INTEGER_LITERAL> ...
> > <FLOAT_LITERAL> ...
> > "{" ...
> > "empty" ...
> > "(" ...
> > "size" ...
> > "-" ...
> > "~" ...
> > "!" ...
> > "not" ...
> > "null" ...
> > "true" ...
> > "false" ...
> > ";" ...
> > "if" ...
> > "while" ...
> > "foreach" ...
> > <IDENTIFIER> ...
> > <STRING_LITERAL> ...
> > ):
> >
> > Is creating arrays (or HashMaps, for that matter) even possible like this
> in
> > SCXML? I was following the guide at:
> > http://commons.apache.org/jexl/reference/syntax.html
> >
> > The executor was created like this:
> >
> > SCXMLExecutor exec = null;
> > exec = new SCXMLExecutor(new JexlEvaluator(), new
> > SimpleDispatcher(), new SimpleErrorReporter());
> > Context ctx = new JexlContext();
> > exec.setRootContext(ctx);
> > exec.setStateMachine(scxml);
> > exec.setSuperStep(true);
> >
> > Thank you!
> >
> <snip/>
>
> JEXL 2.x syntax will require a suitable Evaluator/Context
> implementation (the default in v0.9 supports JEXL 1.x). You can either
> provide one yourself or try the one attached to this ticket [1].
>
> -Rahul
>
> [1] https://issues.apache.org/jira/browse/SCXML-114
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
Re: [scxml] Creating ad-hoc arrays in JEXL expressions
Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, May 9, 2011 at 4:19 PM, Dario D <da...@gmail.com> wrote:
> Hello,
>
> I am trying to create an ad-hoc array in my workflow and provide it to a
> custom action:
>
> <state id="fetchCustomerData">
> <onentry>
> <log expr="'Customer - Fetching data'"/>
> <al:fetchTableData select="['col1', 'col2']" />
> </onentry>
> </state>
>
> In the custom action, I am evaluating this string through JEXL Evaluator:
>
> public void execute(EventDispatcher eventDispatcher, ErrorReporter
> errorReporter, SCInstance scInstance, Log log, Collection collection) throws
> ModelException, SCXMLExpressionException {
> log.info(scInstance.getEvaluator().eval(scInstance.getRootContext(),
> this.getSelect()));
> }
>
> This throws an error:
>
> WARNING: EXPRESSION_ERROR (eval('['col1', 'col2']'):Encountered "[" at line
> 1, column 1.
> Was expecting one of:
> <EOF>
> <INTEGER_LITERAL> ...
> <FLOAT_LITERAL> ...
> "{" ...
> "empty" ...
> "(" ...
> "size" ...
> "-" ...
> "~" ...
> "!" ...
> "not" ...
> "null" ...
> "true" ...
> "false" ...
> ";" ...
> "if" ...
> "while" ...
> "foreach" ...
> <IDENTIFIER> ...
> <STRING_LITERAL> ...
> ):
>
> Is creating arrays (or HashMaps, for that matter) even possible like this in
> SCXML? I was following the guide at:
> http://commons.apache.org/jexl/reference/syntax.html
>
> The executor was created like this:
>
> SCXMLExecutor exec = null;
> exec = new SCXMLExecutor(new JexlEvaluator(), new
> SimpleDispatcher(), new SimpleErrorReporter());
> Context ctx = new JexlContext();
> exec.setRootContext(ctx);
> exec.setStateMachine(scxml);
> exec.setSuperStep(true);
>
> Thank you!
>
<snip/>
JEXL 2.x syntax will require a suitable Evaluator/Context
implementation (the default in v0.9 supports JEXL 1.x). You can either
provide one yourself or try the one attached to this ticket [1].
-Rahul
[1] https://issues.apache.org/jira/browse/SCXML-114
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org