I need some clarification on what is happening when I mix naked EL
expressions with Struts tags in a JSP page.
To put this in context, lets say I have an action that makes a "product"
object available to the view via a getter (in the action). In the JSP
view I can do this:
${product.name}
And I can do this...
<s:iterator id="productItem" value="product.getProductItems()" >
${productItem.name}
</s:iterator>
So this clearly works. I can mix naked EL expressions and Struts tags
into my JSP page. The naked EL expressions have access to at least some
portion of the OGNL stack.
So now I need some clarification as to what's really going on here.
Questions...
1) What EL language can I write the naked EL expression in?
Is it provided by the Servlet container? I'm currently using Tomcat 5.5
which implements JSP 2.0 and EL portion of JSP with Commons EL. So I'm
using commons EL, righ?
Following that logic, if I switched to GlassFish for my server, I'd then
be using Unified EL, right?
Or is the EL available in these Struts JSP views something that struts
is providing? Like is Struts swapping in OGNL, MVEL, or JEXL behind the
scenes?
2) What "context" is the EL evaluated against?
A JSP 2.0 "standard" expression has a bunch of implicit objects
available to it (page, request, etc.) none of which would normally
contain the "product" object that I reference in example above.
Nor woudl the productItem object normally be available to the EL
expression, it's added to the top of the OGNL stack by the Struts
iterator tag.
So Struts is obviously doing some magic to extend the standard EL context.
So how's that happening? I'd like the details of the "context" the EL
is executing against. How is the OGNL stack shared with the EL context?
Is it just copying portions of the OGNL stack into the EL "page"
context or something?
3) What libs are required to use EL in this way?
I've always associated EL with JSTL so I kinda figured that I'd need the
JSTL libs. But I just removed the JSTL libs from my project and the
naked EL stuff still works great. Also cool.
So now I'm thinking that all I need is a JSP 2.0 container (and the
built-in libs it provides)? Is that the requirement to make the EL
magic work?
4) How do I get things like the "top" of the stack?
In the iterator example above I had to assign an ID to the iterator tag
so that I had something to reference in my naked EL expression.
Is this a requirement or is there some naked EL expression that will let
me get arbitrary properties of the OGNL stack (like the top, for example).
----
I sort of stumbled onto this combination of view-technologies after a
bunch of googling. And I'd go so far as to say this is *the* sweet-spot
if I'm forced to use JSP views with Struts (instead of, say, Velocity or
Freemarker).
It gives me the ability to do very clean string/value interpolations (I
hate using tags for string/value interpolation) while still using the
Struts taglib where appropriate.
Shouldn't this be doc'd better? Or is it and I just missed it? Am I
the only one who thinks this rocks?
Thanks!
- Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]