struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan Schröder" <simon.v...@gmx.de>
Subject Re: OGNL
Date Fri, 22 Aug 2008 12:42:31 GMT
Here are the language and developer guides:
http://www.opensymphony.com/ognl/

I'm pretty sure that neither %{} nor ${} are actually part of OGNL. %{} is a marker for struts2
that the content should be evaluated as OGNL-Statement and not as String while ${} is the
marker for freemarker, which is used in Struts2 to generate html from tags, that the content
should be evaluated with a customized data model which wraps the value stack.
The ValueStack isn't part of OGNL either. It's just a class with the special behavior regarding
to OGNL. Normally OGNL walks the object path like this:
>>>>>>>>>>>>>>>>>>>>>
Map m = new Map();
m.put( "model",new DomainModel() ); //DomainModel has the Property id;
<<<<<<<<<<<<<<<<<<<<<
OGNL can now retrieve the ID with "m['model'].id"

The Value Stack now hides the fact that it's not the value stack that has a property but object
that was given to it.
>>>>>>>>>>>>>>>>>>>>>>
ValueStack v = new ValueStack();
v.push( new DomainModel() ); 
<<<<<<<<<<<<<<<<<<<<<<
this is why OGNL can now ask "v.id" (and not "v.top.id") as if the ID was a property of the
stack.

Because the Actionclass-Instance is added to the ValueStack automatically and every expression
is evaluated against the value stack you can write "id" and retrieve the getId()-property
of the action.

The action is the root of the context map wich uses OGNL as a starting point therefore you
don't need the '#'-before the name of the variable. 

Normally when looking for a property on the value stack the first occurence of it (starting
at the top of the stack) is returned. But some tags (eg. property) only evaluate 'top' which
is the last element that was pushed on the Value Stack (which is the action instance itself
at the start of the evaluation of you JSP/Freemarker/Velocity page).

/Stephan


-------- Original-Nachricht --------
> Datum: Fri, 22 Aug 2008 17:32:34 +0530
> Von: "Muralidhar Y" <muralidhary@kensium.com>
> An: "\'Struts Users Mailing List\'" <user@struts.apache.org>
> Betreff: OGNL

> Hi friends,
> 
>                  How to understand the OGNL. I am working with it,  most
> of
> the time I guess the things but I want to know how exactly the OGNL works.
> What is value stack? What is root and exactly how to write OGNL? Apart of
> the doc that is there on struts site, is there any good tutorial for OGNL
> so
> that I don't need to guess when writing OGNL when writing jsp pages using
> struts? I am really confused? Sometimes we use "%{}" notation, sometimes
> we
> use "${}" notation? Which is OGNL? I am really confused? Kindly help me in
> this.   
> 
>  
> 
> Warm regards,
> 
> Muralidhar Y
> 
> muralidhary@kensium.com
> 
>  
> 
> US Main: 877 KENSIUM (536.7486)
> India Main:  +91 9949495511
> 
> India Fax:   +91 9949495522
> 
> Kensium
> 
> 200 S Wacker Dr, Suite 3100
> 
> Chicago, IL 60606
> 
>  
> 
>  
> 
> Confidentiality Note:
> -----------------------------
> The information contained in this e-mail is strictly confidential and for
> the intended use of the addressee only. Any disclosure, use or copying of
> the information by anyone other than the intended recipient is prohibited.
> If you have received this message in error, please notify the sender
> immediately by return e-mail and securely discard this message.
> 
>  
> 
>   _____  
> 
>  
> 

-- 
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196

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


Mime
View raw message