Re: [jexl] EL-style string evaluations

2006-06-20 Thread Hubert Rabago

On 6/19/06, Rahul Akolkar [EMAIL PROTECTED] wrote:


I suspect you can try:

String expr =  ' JEXL lets you do everything you would do with EL. '
+ thingy.foo 

for the desired outcome (whitespace exaggerated for readability in email).

-Rahul


Thanks, Rahul.

I have tried it that way.  I just wanted to verify that what I was
seeing is what was intended.

Hubert

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [jexl] EL-style string evaluations

2006-06-19 Thread Rahul Akolkar

On 6/19/06, Hubert Rabago [EMAIL PROTECTED] wrote:

Is the sample in this message valid:
http://marc.theaimsgroup.com/?l=jakarta-commons-userm=111974074105369w=2


snip/

No, its not.



   SomeObject thingy = new SomeObject();
   thingy.setFoo( Blah );

   String expr =
   JEXL let's you do everything you'd do with EL. ${thingy.foo};


snap/

Two issues about parsing that:

* Single quotes demarcate String literals, and cannot be used at will like that
* JEXL has no concept of ${...} and will not attach any semantics to
the construct

I suspect you can try:

String expr =  ' JEXL lets you do everything you would do with EL. '
+ thingy.foo 

for the desired outcome (whitespace exaggerated for readability in email).

-Rahul



   Expression e = ExpressionFactory.createExpression( expr );
   JexlContext jc = JexlHelper.createContext( );
   jc.getVars( ).put(thingy, thingy);
   String message = (String) e.evaluate(jc);

I need this functionality in my app.  I tried out the code above but got this:

org.apache.commons.jexl.parser.ParseException: Encountered let at
line 1, column 6.
Was expecting one of:
   || ...
   ... etc ...
   at 
org.apache.commons.jexl.parser.Parser.generateParseException(Parser.java:3274)
 ... etc ...

What's the proper way of evaluating expr in the sample above using JEXL?

thanks,
Hubert



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]