tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: How to use JSTL engine to evaluate exprs in a "context"?
Date Thu, 22 Aug 2002 15:35:22 GMT
On 19 Aug 2002, David M. Karr wrote:

> I think I now understand how to do part of this, which is to define a
> "resolveVariable()" method in a "VariableResolver" subclass which just
> uses "BeanUtils.getProperty(beanName, pName)" (where "pName" is the
> variable to be resolved).  I wonder, however, if I would be looking up
> the beanName explicitly here, or whether I would have that being sent
> in as the "pContext"?

Hi David,

I think I've lost track of how far along you are in this project.  As an
attempt to answer this specific question, keep in mind that the 'pContext'
argument typically represents the PageContext in a JSP page.  You're more
than welcome to restrict the scope of an evaluation and set the bean
itself to be the context, however.

Still, I'm not sure I see why you want to preserve that much of the
structure of the original Struts attributes.  Instead of property/name,
why not just a simply 'value' that takes a whole EL expression.  This
might be more intuitive, since it'll match uses of the EL within template
text and non-Struts attributes (as well as JSTL 1.0 tags).  You get some
syntactic conciseness from restricting the scope of these expressions, but
is that worth the extra learning curve for the users?

> Outside of this, I still don't see how I can fit a derived
> VariableResolver into a framework that would allow me to evaluate EL
> expressions with it.

Please let me know if you've got any further questions.  I'm not sure I
understand this specific question -- you pass VariableResolver to an
evaluate() method to inform an Expression or ExpressionEvaluator of the
procedure you wish to use to resolve top-level objects (including
potentially "implicit" objects) in your environment.

As a suggestion that adds to the one I made above, what if you simply
extend the JSTL VariableResolver in order to add new implicit
objects?  This way, a user could always write ${sessionScope.userName} if
he or she wanted to do so, but could conveniently access a current form or
other special object with an expression like ${form.foo}.  Of course, if
you simply make 'form' a scoped variable (that is, scoped attribute), you
effectively get this for free.

Hope that helps - and again, please send followup questions.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message