File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Binding values into views" Watch "Binding values into views" New topic

Binding values into views


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: 471

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 ( - 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:
Kazeem Akinrinde

Joined: Aug 24, 2002
Posts: 21
this link will help to get the basic understanding of value stack. This
is also a detailed documentation of value stack
I agree. Here's the link:
subject: Binding values into views
It's not a secret anymore!