Hi,
After digging around in the archive, I found what I consider to be the best
and clearest example of pager taglib. It helped me a lot. Maybe this will save
someone some digging. This example was written and posted in 2002 by Thomas
Gigen (thank you Thomas!). I have copied it in below, along with the original
message header, (if you want to see the original thread, obviously just search
the subject listed below):
From: Thomas, Gigen <[EMAIL PROTECTED]>
Subject: pager taglib !!
Date: Mon, 17 Jun 2002 14:23:38 -0700
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C21645.3EAF8A22"
Hi John,
You can use a logic:iterate tag to loop through a Collection of results.
Here is an example of what I have done.Let me know if this helps you.
Results are contained in a LinkedList - results .
Set up the pager:url ,maxPageItems and the itemCount attribute
url="stationsearch.htm" maxPageItems="<%=maxPageItems%>"
itemCount="<%=itemCount%>">
Regards,
Gigen Thomas
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/pager-taglib.tld" prefix="pg" %>
<html:html>
<head>
<title>STARS Search Results</title>
<LINK href="/stars/theme/search.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!-- Begin
function LoadPage(page , x) {
this.form.submit(page+"?id="+x);
window.setTimeout("window.close()",800)
}
// End -->
</script>
</head>
<body bgcolor="#EDF3FF" link="#000257" vlink="#000257">
<jsp:useBean id="results" class="java.util.LinkedList" scope="request" />
<%
int arraySize = 0 ;
arraySize = results.size() ;
%>
<html:form action="/stationsearch">
<table border="0" width="600" cellpadding="0" cellspacing="0"
bgcolor="#EDF3FF">
<tbody>
<tr>
<td valign="top"><img
src="/stars/images/search/search_banner.gif" border="0" width="600"
height="57"></td>
</tr>
<tr>
<td valign="top" align="left" width="600"
bgcolor="#99CCCFF"><img src="/stars/images/wizard/blank.gif" border="0"
width="1" height="2"></td>
</tr>
<tr>
<td valign="top" align="left" width="600"
bgcolor="#FFFFFF"><img src="/stars/images/wizard/blank.gif" border="0"
width="1" height="1"></td>
</tr>
<tr>
<td valign="bottom">
<%
String sourcePage = (String)request.getAttribute("sourcepage") ;
int maxPageItems = 0 ;
Integer maxItems = (Integer)request.getAttribute("itemsPerPage") ;
if ( maxItems !=null )
maxPageItems = maxItems.intValue();
String maxPageItemsStr = String.valueOf(maxPageItems) ;
int itemCount = 0 ;
Integer count = (Integer)request.getAttribute("itemCount") ;
if (count != null)
itemCount = count.intValue();
%>
<table border="0" width="600"
cellpadding="3" cellspacing="0" align="center" bgcolor="#EDF3FF">
<tbody>
<tr>
<td
valign="top"><font size="2">Item count :<b> <%=itemCount%></b></font>
<pg:pager url="stationsearch.htm" maxPageItems="<%=maxPageItems%>"
itemCount="<%=itemCount%>">
<pg:param name="maxPageItems" value="<%=maxPageItemsStr%>"/>
<pg:param name="q"/>
<pg:item>
</pg:item>
<pg:index>
<pg:prev>
<td valign="top"><a href="<%= pageUrl %>"><img
src="/stars/images/search/arrow_left.gif" border="0" width="20"
height="15"></a></td>
</pg:prev>
<pg:pages><td valign="top"><font size="2">
<%
if (pageNumber.intValue() < 2) {
%> <%
}
if (pageNumber == pagerPageNumber) {
%><%= pageNumber %><%
} else {
%><a href="<%= pageUrl %>"><b><%= pageNumber %></b></a><%
}
%>
</font></td>
</pg:pages>
<pg:next>
<td valign="top"><a href="<%= pageUrl %>"><img
src="/stars/images/search/arrow_right.gif" border="0" width="20"
height="15"></a></td>
</pg:next>
</pg:index>
</pg:pager>
<td><img
src="/stars/images/search/blank.gif" border="0" width="70" height="1"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top">
<TABLE border="1" cellpadding="2"
cellspacing="0" align="center" bgcolor="#EDF3FF" width="100%">
<TBODY>
<%
String elementName = "" ;
%>
<logic:iterate id="item" name="results" indexId="index">
<tr>
<logic:iterate
id="element" name="item" property="propertyNames" indexId="index2">
<%
elementName
= (String)pageContext.getAttribute("element") ;
%>
<td
valign="top"><font size="1">
<bean:write
name="item" property="<%=elementName%>"/>
</td>
</logic:iterate>
</tr>
</logic:iterate>
</TBODY>
</TABLE>
</td>
</tr>
</tbody>
</table>
</html:form>
</body>
</html:html>
Heather Buch
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]