You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by dh...@lexmark.com on 2001/04/27 21:28:42 UTC

Iterate certain number of times?


Hi.

Am wanting to iterate a certain number of times, based on a value in my form
bean, to create a set of page links for the number of pages the user can view
(similar to at the bottom of most search engine results).

How do I do this with Struts?  Obviously I am not iterating over a collection.
But surely it is possible - what am I missing?

Many thanks,

Dave




Re: Iterate certain number of times?

Posted by Vincent Moynihan <vi...@btinternet.com>.
Dave
Try the pager taglib from jsptags.com
http://jsptags.com/tags/

Vince
----- Original Message -----
From: <dh...@lexmark.com>
To: <st...@jakarta.apache.org>
Sent: Friday, April 27, 2001 8:28 PM
Subject: Iterate certain number of times?


>
>
> Hi.
>
> Am wanting to iterate a certain number of times, based on a value in my
form
> bean, to create a set of page links for the number of pages the user can
view
> (similar to at the bottom of most search engine results).
>
> How do I do this with Struts?  Obviously I am not iterating over a
collection.
> But surely it is possible - what am I missing?
>
> Many thanks,
>
> Dave
>
>
>
>


RE: Iterate certain number of times?

Posted by Niall Pemberton <ni...@btInternet.com>.
I know its not that elegant, but generate an array of page numbers in your
ActionForm based on the count

private int pageCount;

public String[] getPages() {

  String[] pages = new String[pageCount];

  for (int i = 0; i < pageCount; i++) {
    int j = i + 1;
    pages[i] = ""+j;
  }

  return pages;

}

Alternatively, write your own Tag which will look up a specified value in
your bean and loop the appropriate number of times.

Niall

> -----Original Message-----
> From: dhay@lexmark.com [mailto:dhay@lexmark.com]
> Sent: 27 April 2001 20:29
> To: struts-user@jakarta.apache.org
> Subject: Iterate certain number of times?
>
>
>
>
> Hi.
>
> Am wanting to iterate a certain number of times, based on a value
> in my form
> bean, to create a set of page links for the number of pages the
> user can view
> (similar to at the bottom of most search engine results).
>
> How do I do this with Struts?  Obviously I am not iterating over
> a collection.
> But surely it is possible - what am I missing?
>
> Many thanks,
>
> Dave
>
>
>
>


RE: Iterate certain number of times?

Posted by Karl Basel <kb...@freemail.absa.co.za>.
Hi,

There's a good pager taglib at jsptags.com. I've used it in a struts app and
does the job quite well when embedded in the iterate tags.

<logic:iterate>
   <pg:item>
 	Item Details
   </pg:item>
</logic:iterate>

Hope it helps,
karl

-----Original Message-----
From: dhay@lexmark.com [mailto:dhay@lexmark.com]
Sent: 27 April 2001 09:29
To: struts-user@jakarta.apache.org
Subject: Iterate certain number of times?




Hi.

Am wanting to iterate a certain number of times, based on a value in my form
bean, to create a set of page links for the number of pages the user can
view
(similar to at the bottom of most search engine results).

How do I do this with Struts?  Obviously I am not iterating over a
collection.
But surely it is possible - what am I missing?

Many thanks,

Dave