You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Zoran Avtarovski <zo...@conads.com> on 2003/02/04 13:14:55 UTC
Pager tag troubles
Hi,
I've got a struts application which displays lists of information from a
database. I use a action class to retrieve and place the information into a
Collection which I then return to a display jsp. Pretty standard stuff.
In the jsp page I am using the iterate tag to display the collection.
Everything works well, except that the pages were getting a little on the
long side, so I though rather than writing pagination code from scratch I'd
use James Klicman's pager tag which offered a quick and easy solution.
I'm having problems getting the page to work with my page. I can get the
example to run without a hitch, but that uses a for-next loop with some code
on the page. Has anybody gotten the pager tag to work with an iterate tag
and if so can you please send me some sample code.
Or, am I better off writing some code into my action classes which pass an
offset value, and some display parameters with each request?
Any help would be greatly appreciated.
Zoran
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Pager tag troubles
Posted by paul miller <pa...@yahoo.com>.
http://jsptags.com/tags/navigation/pager/index.jsp
A wonderfull pager.
If you want the pager "nav bar" before your iterator you need to tell it the
size
(Its described in the pager docs) you could use the <bean:size/> struts tag
I use a "listInfo" bean that hold the size and the name of the list.
My pager "nav bar" has
<%-- expost listInfo.name --%>
<bean:define id="name" name="listInfo" property="name"/>
Displaying <%= name %> <%= firstItem %>-<%= lastItem %> of <%= totalItems %>
Where name is something like "USERS"
But thats just eye candy
I'm cutting and pasting out of a working jsp, sorry if I miss something
<%-- expose the listInfo.size --%>
<bean:define id="size" name="listInfo" property="size"
type="java.lang.Integer" />
<pg:pager
items="<%= size.intValue() %>"
index="center"
maxPageItems="10"
maxIndexPages="10"
export="offset,currentPageNumber=pageNumber"
url="/Foo.do"
scope="request">
<%-- keeps the pager on the correct page --%>
<input type="hidden" name="pager.offset" value="<%= offset %>">
<tr>
<td colspan="3" align="center">
<jsp:include page="pagerNavBar.jsp" flush="true"/>
</td>
</tr>
<logic:iterate id="bar" name="barList">
<pg:item>
<bean:write name="bar" property="name" />
</pg:item>
</logic:iterate>
<tr>
<td colspan="4" align="center">
<jsp:include page="pagerNavBar.jsp" flush="true"/>
</td>
</tr>
</pg:pager>
Nice and simple :)
I use links to go out of the pager, so I tack the pager.offset on the href url
and send the pager.offset back when returning to the pager.
--- Zoran Avtarovski <zo...@conads.com> wrote:
> Hi,
>
> I've got a struts application which displays lists of information from a
> database. I use a action class to retrieve and place the information into a
> Collection which I then return to a display jsp. Pretty standard stuff.
>
> In the jsp page I am using the iterate tag to display the collection.
>
> Everything works well, except that the pages were getting a little on the
> long side, so I though rather than writing pagination code from scratch I'd
> use James Klicman's pager tag which offered a quick and easy solution.
>
> I'm having problems getting the page to work with my page. I can get the
> example to run without a hitch, but that uses a for-next loop with some code
> on the page. Has anybody gotten the pager tag to work with an iterate tag
> and if so can you please send me some sample code.
>
> Or, am I better off writing some code into my action classes which pass an
> offset value, and some display parameters with each request?
>
> Any help would be greatly appreciated.
>
> Zoran
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org