This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Binding values into views Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Binding values into views" Watch "Binding values into views" New topic
Author

Binding values into views

DINESH MISHRA
Greenhorn

Joined: Jan 07, 2001
Posts: 6
What is "value Stack" used in Struts 2? Could anybody explain it with example?
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
This is probably not what you're asking, but it does contain some useful information regarding value stack.



SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
This article is quiet valuable. I got this excerpt form it
The Struts2 s roperty tag is very similar to the c ut tag. It uses an expression language to obtain a value, and the value can also be found by searching through an object graph using dot notation. There are two major differences. The first is that OGNL - Object Graph Navigational Language (http://opensymphony.com/ognl) - is used as the expression language. So not only can you use the dot notation to find values to display, you can also use advanced features such as object method calls, projection and lambda expressions. This is an open source project and developed independently of Struts2.

The second difference is that a scope is not required. This is both an advantage and a disadvantage. Instead of different scopes that the JSP developer needs to explicitly specify, Struts2 has a Value Stack. The Value Stack is just an order of different scopes that is traversed when looking for a value. When looking for a value, if a getter for the field is not found in one scope, the next scope is checked - this continues until either the field is found or all the scopes have been exhausted. The order of the scopes is:

1. Temporary Objects - these are objects that are created in the JSP page (we will see an example soon with the s:url tag), or they are objects created by tags that have short lives (such as the current object during a loop over a collection).
2. The Model Object - if model objects are being used, they are checked next (before the action).
3. The Action Object - this is the action that has just been executed. Hence, without explicitly placing the action in a session or request scope, you will still have access to its data.
4. Named Objects - these objects include #application, #session, #request, #attr and #parameters and refer to the corresponding servlet scopes.


Visit my blog: http://jnassef.blogspot.com/
Kazeem Akinrinde
Greenhorn

Joined: Aug 24, 2002
Posts: 21
this link http://struts.apache.org/2.x/docs/value-stack-internals.html will help to get the basic understanding of value stack. This http://www.opensymphony.com/webwork_old/src/docs/manual/fundamentals-valuestack.html
is also a detailed documentation of value stack
 
Don't get me started about those stupid light bulbs.
 
subject: Binding values into views