You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@gmail.com on 2007/04/26 22:44:55 UTC

OGNL

I encountered a situation today that seems to disprove the following
documentation.  I have an Action class with a property that my JSP can only
access if I DO NOT include the #.  If I prepend the #, it is not found.

"The Action instance is always pushed onto the value stack. Because the
Action is on the stack, and the stack is the OGNL root, references to Action
properties can omit the # marker. But, to access other objects in the
ActionContext, we must use the # notation so OGNL knows not to look in the
root object, but for some other object in the ActionContext.""\

-- 
Scott
stanlick@gmail.com

Re: OGNL

Posted by Ted Husted <hu...@apache.org>.
I believe you would need to include the name of the action object as
part of the # reference, as we do with the session and request
objects.

The idea behind the root object is that we don't need to refer to the
object by name, since it is the "root". WW2 and S2 extend the OGNL
notion of a root object to include a "stack" of objects.

But when an object is not the root, we must refer to both the object
and the property names.

-Ted.

On 4/26/07, stanlick@gmail.com <st...@gmail.com> wrote:
> I encountered a situation today that seems to disprove the following
> documentation.  I have an Action class with a property that my JSP can only
> access if I DO NOT include the #.  If I prepend the #, it is not found.
>
> "The Action instance is always pushed onto the value stack. Because the
> Action is on the stack, and the stack is the OGNL root, references to Action
> properties can omit the # marker. But, to access other objects in the
> ActionContext, we must use the # notation so OGNL knows not to look in the
> root object, but for some other object in the ActionContext.""\
>
> --
> Scott
> stanlick@gmail.com
>


-- 
HTH, Ted <http://www.husted.com/ted/blog/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: OGNL

Posted by Dave Newton <ne...@yahoo.com>.
--- stanlick@gmail.com wrote:
> I encountered a situation today that seems to
> disprove the following documentation.  I have an 
> Action class with a property that my JSP can only
> access if I DO NOT include the #.  If I prepend the
> #, it is not found.
> 
> "The Action instance is always pushed onto the value
> stack. Because the Action is on the stack, and the 
> stack is the OGNL root, references to Action
> properties can omit the # marker. But, to access
> other objects in the ActionContext, we must use the
#
> notation so OGNL knows not to look in the root 
> object, but for some other object in the
> ActionContext.""\

If you include the "#" doesn't OGNL *not* look at the
root (your action), so it would try to find a non-root
object with the name you've given it?

I mean, if my action exposes

public String getStringBean() { ... }

and I use

<s:property value="%{#stringBean}"/>

it's going to look at *rest* of the stack for
something called "stringBean", not at my action, which
is on the root. If I use

<s:property value="#root.stringBean"/>

then it will display (or, obviously,
value="stringBean").

Maybe I'm misunderstanding what you're saying.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org