Perhaps the language is bad, but what I believe that documentation means is
that when you are iterating the each object in the iteration is at the top
of the stack so that when you do something like this:

<s:iterator value="#session.users">
    <s:property value="firstName"/>
</s:iterator>

Struts knows that you mean #session.users[i].firstName.  It knows that based
on how the value stack works.  


Here is a quote from an infoq.com article describing the Value Stack:

http://www.infoq.com/articles/migrating-struts-2-part3 wrote:
> 
>  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.
> 
> The advantage is clear - each scope, in turn, is checked for the field
> that you are after. However, if you have both a model object and action
> with the same field name (set's say "id"), then problems can occur. If you
> want the models value the correct result will be returned - but if you
> want the actions value, you will be returned the models value, as the
> model scope precedes the action scope. The solution is to provide a
> qualifier determining where in the stack you want to retrieve the "id"
> field - in this example "[1].id" would retrieve the value from the action.
> More information can be found online at
> http://cwiki.apache.org/WW/ognl-basics.html.
> 

So now you realize that instead of #session.users to get to your list you
can just use users and it will search until it finds the "users" list in
your session.

  

jo_atman wrote:
> 
> Sorry if this is too basic, but i seem to be missing something.
> The iterator tag documentation says it iterates over the value on top of
> the stack. 
> I don't understand what this stack is and what is at the top of the stack.
> 
> Can i use the iterator tag to iterate over an object stored as a session
> attribute?
> 
> Any help much appreciated!
> 

-- 
View this message in context: 
http://www.nabble.com/basic-question-about-%3Cs%3Aiterator%3E-tp24141202p24141965.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to