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] jsp test
Date Thu, 09 Feb 2006 16:21:38 GMT
On 2/8/06, 박성찬 <schanpark@gmail.com> wrote:
> In the context of RootContextTest.java,
> there is an assignment "jspCtx.setAttribute("foo", "1");"
> but when I tried to set "foo.bar" instead of "foo", it didn't work.
> It probably didn't match the context in the scxml script (<if cond="${empty(
> foo.bar)}">).
> Tracing the EL parser, it divided two("foo" and "bar") as complex variable.
> How can you solve this?
>
<snip/>

EL is a simple expression language, and the dot operator precludes its
use in variable names. However, depending on what you're trying to do,
you may still be able to get by. Common exceptions to the above rule
include keys (maps, resource bundles), for which the [] operator may
be used instead. For example, if  "foo.bar" is a key in a map stored
in variable "map", the corresponding EL expression can be used to
retrieve the value.

${map['foo.bar']}

On the other hand, I'm not sure what your particular use case is since
you refer to a test class in the SCXML test suite. Do you need EL? Are
you using SCXML in a JSP-based environment? If not, I'd recommend
using JEXL [1] for expressions instead. This page [2] has a brief
description of how to use JEXL in SCXML documents. Ofcourse, feel free
to ask here if you have other questions. JEXL also has a FlatResolver
[3] which might be useful in your case. The SCXML JEXLEvaluator class
does not support preresolvers and postresolvers yet, but its not much
work at all so if you have a good use case, I can add that capability
fairly quickly.

-Rahul

[1] http://jakarta.apache.org/commons/jexl/
[2] http://jakarta.apache.org/commons/sandbox/scxml/api-notes/testing-standalone.html
[3] http://jakarta.apache.org/commons/jexl/apidocs/org/apache/commons/jexl/resolver/FlatResolver.html


> Sungchan
>
>
Mime
View raw message