tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helios Alonso <>
Subject Re: Dynamic Expressions for Struts-EL and JSTL
Date Thu, 02 Sep 2004 14:48:14 GMT
if you have a property in any bean you can write this:




(I didn't use it but reading a tutorial it was a big surprise for me).

So, you could change this:

>String expr = "formBean." +

to this:


(If I understood you have a layoutObject with a property saying which 
property read from formBean).

At 08:37 02/09/2004 -0500, you wrote:

>I'm using the Struts-EL and JSTL custom tag implementations in my Web app.
>I want to use the c:out tag to output dynamic data.  The tricky part is I
>want to dynamically build the EL expression at runtime by building up a
>String that should be evaluated.  I don't want to output the String, I want
>the String to be evaluated by the expression engine and then that written
>out.  An example follows below.
>//Assume that after this line runs, expr has a value of
>//This is the expression I want evaluated
>String expr = "formBean." +
>pageContext.setAttribute("expr", expr);
><c:out value="Expression Value is: ${expr}" />
>The c:out tag above renders the text Expression Value is:
>  .
>This isn't what I want -- I want it to evaluate the
>down to an expression, and then spit out the value of that expression
>(basically, formBean.getProperty().getValue() ).
>Interestingly, if I "hard code" the expression, it works:
><c:out value="${}"/>
>The only problem is I need to dynamically change this expression at runtime.
>Can this be done?  If so, how?  I'm hoping so otherwise I'll have a mountain
>of new code to write.  Also, is there a more elegant way to do what I show
>in the example above, like using tags instead of scriptlets?  I don't care
>if I use Struts-EL tags, JSTL tags, or both.
>Thank you very much!!
>This e-mail message is being sent solely for use by the intended 
>recipient(s) and may contain confidential information.  Any unauthorized 
>review, use, disclosure or distribution is prohibited.  If you are not the 
>intended recipient, please contact the sender by phone or reply by e-mail, 
>delete the original message and destroy all copies. Thank you.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message