On 08-10-14 11:31, R.C. Hoekstra wrote:
Hi Rinke, I think you would get a node if you used DataNode function
instead: <cs:var name="treatment1Name"
expr="DataNode(treatmentData,'treatments/treatment[1]/name')" /> Could you
try that?
Regards, Woonsan
Hi Woonsan,
thanks for your answer. But are you sure about that? If I use it like that, I
get an "unknown, ambiguous or inaccessible method dataNode" error.
Correct, DataNode() is not a function available (registered) within the context
of the expression evaluator.
I found the dataNode method in Builtin.java. Its javadoc says:
"Manifests within location attribute of <assign> element, for Commons JEXL
and Commons EL based documents."
So what I get from it, is that dataNode can only be used to assign something
to a dataNode via <assign>.
That is not what I want. I want to pass a dataNode including subElements to
some java object via the cond attribute, so I can write a java method which
is able to check conditions with use of the passed dataNode.
So: is there a way in which I can pass a dataNode to a java object in the
context which is used in a cond attribute? Data obviously doesn't work, as I
can see in the Builtin code that it always is parsed to Double or String.
Not by the SCXML spec, and neither (directly) through Commons SCXML extensions.
However, it should be trivial to add such functionality yourself through a
custom Action. Then you can access and use the Builtin#dataNode method and do
whatever you like with a data node element.
For a quick intro in writing a custom Action (for Commons SCXML 2.0), see for
example slides 12,13 of my presentation at the ApacheCon earlier this year:
http://events.linuxfoundation.org/sites/events/files/slides/ApacheConUS2014%20-%20Apache%20Commons%20SCXML%202.0.pdf
and I suggest looking at the Commons SCXML Var action as simply example.
HTH, Ate
best regards, Rinke
On Thursday, October 2, 2014 3:53 AM, R.C. Hoekstra
<[email protected]> wrote:
Hi list, Hi people @ scxml commons,
Can I pass datamodel nodes to a rootContext var, in order to process it
in java?
like this: <target event="bla" cond="agent.check(datamodelNodeRef)"
.../>, where: * agent is an object of a java class made available to the
RootContext, having a check method returning Boolean. I want this check
method to evaluate the datamodelNode, in order to return true or false
depending on elements. * datamodelNodeRef is a reference to some node in
the datamodel.
I managed to pass final nodes as string here, like this:
<cs:var name="treatment1Name"
expr="Data(treatmentData,'treatments/treatment[1]/name')" />, <transition
... cond="agent.check(treament1Name)"...
where the treatments/treatment[1]/name is a final node.
However, I would like to pass non final nodes of the datamodel, but
everything seems to be evaluated as strings first, before it is passed
into the method of the context var.
Hope you can give me a clue.
And, if these kind of constructions are possible, how would they do in
terms of performance?
thanks, Rinke
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]