You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Struts Two <st...@yahoo.ca> on 2008/11/01 00:45:52 UTC

Re: How to run an iterator twice in a page

Please ignore this topic as the problem was due a typo in my jsp. I apologize for wasting your time on an issue that is not a problem, I should have checked more carefully.

regards,



----- Original Message ----
From: Struts Two <st...@yahoo.ca>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Friday, October 31, 2008 5:43:55 PM
Subject: Re: How to run an iterator twice in a page

I was hoping to find a better way to do this for a case as simple as the this one rather than resorting to hacks. Normally in JSTL when c:foreach is used a new iterator is created. I also tried the following in the second iterator but of no avail

<s:iterator value="[1].users" id="u" status="status">

I also tried to move users into request scope [ <s:set id="users" name="users" scope="request" value="users"/>] and then try

<s:iterator value="#request.users" id="u" status="status">

in both iterators, But only the first table is displayed.



----- Original Message ----
From: "Peterson, Ryan" <Ry...@McKesson.com>
To: Struts Users Mailing List user@struts.apache.org
Sent: Friday, October 31, 2008 5:10:39 PM
Subject: RE: How to run an iterator twice in a page

It's sort of "hack-ish", but can you make a copy of the list of users in the Java code, and iterate over the copied list for the 2nd set of results?

-----Original Message-----
From: Struts Two [mailto:strutstwo@yahoo.ca] 
Sent: Friday, October 31, 2008 1:36 PM
To: Struts Users Mailing List
Subject: How to run an iterator twice in a page

I have a list of users and I would like to iterate over this list twice in a page. However in the following code snippet, The list is iterated only once and the second iterator displays nothing.

<p>Table 1</p>
<table cellspacing="1" cellpadding="0" class="basic-table" width="100%">
    <tr class="gray-med-dark">
       <th nowrap="nowrap" scope="col">user id</th>
       <th nowrap="nowrap" scope="col">user name</th>
   </tr>
   <s:iterator value="users" id="u" status="status">
      <tr >
           <td><s:property value="#u.id" /></td>
           <td><s:property value="#u.name" /></td>
      </tr>
   </s:iterator>
</table>

<p>Table 2</p>
<table cellspacing="1" cellpadding="0" class="basic-table" width="100%">
     <tr class="gray-med-dark">
          <th nowrap="nowrap" scope="col">user id</th>
          <th nowrap="nowrap" scope="col">user name</th>
     </tr>
     <s:iterator value="users" id="u" status="status">
      <tr >
           <td><s:property value="#u.id" /></td>
           <td><s:property value="#u.name" /></td>
      </tr>
     </s:iterator>
</table>

In the second iterator I even renamed the id to u1 but of no avail. I think in the first iterator all the user objects are pushed on the top of stack hence users is not availabe on the second iterator. I would appreciate any hints on how to achieve this.


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/


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

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


      __________________________________________________________________
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca


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


      __________________________________________________________________
Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com


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


Re: How to run an iterator twice in a page

Posted by Dale Newfield <da...@newfield.org>.
Struts Two wrote:
> Please ignore this topic as the problem was due a typo in my jsp.

That wasn't your only error.  Remember, having more than one item on a 
single (x)html page with the same id is illegal and may result in 
unexpected behaviors.

-Dale

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