In Manning's book "Struts2 in action" page 106 it is mentioned like
look at this in figure 5.1, you might expect that the expression would need to be something more like. To the contrary, only the user.username necessary. This is because the
myAction.user.usernameis a sort of virtual object that exposes the properties of its contained objects as its own.
If duplicate properties exist—two objects in the stack both have a name
property—then the property of the highest object in the stack will be the
one exposed on the virtual object represented by the.
The value stack looks like a
Stack such a collection of objects that you can access at the top using
peek() and it has a root, that is a compound root due XWork extension of OGNL.
The biggest addition that XWork provides on top of OGNL is the support for the ValueStack. While OGNL operates under the assumption there is only one "root", XWork's ValueStack concept requires there be many "roots".
This compound root has a list of "roots" that are traversed from top (0-index) to down the stack (size()-1) during expression evaluation until the value is found. So each root can contain the value for example
user.username but the first found value will be returned. The problem is how to access those duplicated properties in other "roots". The solution is to access the root by the index. For example top object has prefixed with
. is an object pushed before, and so on. That's how OGNL works on the value stack. You can also see the example where I was trying access action bean properties when model driven is implemented Passing parameters to action through ModelDriven in Struts 2.