Solved

can experts give me a demo use Pager Tag Library.

Posted on 2004-08-09
8
733 Views
Last Modified: 2011-10-03
hi,experts,
 now i down the Pager Tag Library v2.0 in http://jsptags.com/tags/navigation/pager/index.jsp

but i can not use it,can give me a demo?

i hava a java.sql.ResultSet rs.how can i use the Pager Tag Library

<c:set var="sicknessList" value="${idSicknessInfo.getSicknessResult(idSicknessInfo)}"/>
<c:forEach var="sicknessList" items="${sicknessList}">
<pg:item>
  <a href=sicknessInput.jsp?id=${sicknessList.getString("autoid")}>
        <tr onmousemove="this.style.backgroundColor=onmovecolor;" onmouseout="this.style.backgroundColor=''">
            <td></td>
          <td>${sicknessList.getString("SicknessName")}</td>
          <td>${sicknessList.getString("SicknessPYM")}</td>
          <td>${sicknessList.getString("SicknessICD")}</td>
          <td>${sicknessList.getString("SicknessMemo")}</td>
        </tr>
  </a>
</pg:item>
</c:forEach>

can give me a simple demo with Pager Tag Library
0
Comment
Question by:jbas
  • 4
  • 3
8 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 30 total points
ID: 11760204
   <pg:pager index="half-full"
              maxPageItems="5"
              maxIndexPages="10"
              export="currentPageNumber=pageNumber"
              url=""
              scope="request">
      <pg:param name="style"/>
      <pg:param name="position"/>
      <pg:param name="index"/>
      <pg:param name="maxPageItems"/>
      <pg:param name="maxIndexPages"/>
      <c:set var="sicknessList" value="${idSicknessInfo.getSicknessResult(idSicknessInfo)}"/>
      <c:forEach var="sicknessList" items="${sicknessList}">
        <pg:item>
          <a href=sicknessInput.jsp?id=${sicknessList.getString("autoid")}>
             <tr onmousemove="this.style.backgroundColor=onmovecolor;" onmouseout="this.style.backgroundColor=''">
                <td></td>
               <td>${sicknessList.getString("SicknessName")}</td>
               <td>${sicknessList.getString("SicknessPYM")}</td>
               <td>${sicknessList.getString("SicknessICD")}</td>
               <td>${sicknessList.getString("SicknessMemo")}</td>
             </tr>
          </a>
        </pg:item>
      </c:forEach>
      <pg:index export="total=itemCount">
        <table width=100% cellpadding=2 cellspacing=0 border=0 bgcolor=e3e9f8>
        <tr><td><font face=arial size=2>&nbsp;<b>Matches</b></font>
        </td><td align=right nowrap width=1%><font face=arial size=-1>
      <pg:page export="first,last">
          <%= first %> - <%= last %> of <%= total %>
      </pg:page>
      <pg:first export="url" unless="current">
        &nbsp;<b><a href="<%= url %>">First Page</a></b>&nbsp;|
      </pg:first>
      <pg:prev export="url,first,last">
        <% int prevItems = (last.intValue() - first.intValue()) + 1; %>
        <b><a href="<%= url %>">Previous <%= prevItems %></a></b>
      </pg:prev>
      <pg:next export="url,first,last">
        <% int nextItems = (last.intValue() - first.intValue()) + 1; %>
        |&nbsp;<b><a href="<%= url %>">Next <%= nextItems %></a></b>
      </pg:next>
       &nbsp;&nbsp;</font></td></tr>
      </table>
      </pg:index>
    </pg:pager>
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11760212
That's basically from the example that comes with the pager taglib...

There is an example war file, just drop it into tomcat/webapps, and you can look at how it is done for yourself :-)

The pg:index bit is usually loaded in from a seperate jsp file, that means that you can change the style of the pager on the fly :-)

Good luck!

Tim
0
 

Author Comment

by:jbas
ID: 11760372
hi,TimYates
thanks for answer,now i have not get data from rs,this is my code ,where is error!
<%
  java.sql.ResultSet rs=idSicknessInfo.getSicknessResult(idSicknessInfo);
  while(rs.next()){
   out.println(rs.getString("sicknessname"));  //can get date!
  }
%>
<c:set var="rs" value="${rs}"/>
<c:forEach var="rs" items="${rs.rows}">
      <tr><td>${rs.SicknessName}</td></tr>   //no data
</c:forEach>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 11760435
I'd load your resultset into an ArrayList...

Depending on how you have your cursor set up,

  while(rs.next()){

will move the cursor to the end, thn you won't have any data left for the forEach
0
 

Author Comment

by:jbas
ID: 11760596
sorry,when i remove it ,it can not get data either

<%
  java.sql.ResultSet rs=idSicknessInfo.getSicknessResult(idSicknessInfo);
%>
<c:set var="rs" value="${rs}"/>
<c:forEach var="rs" items="${rs.rows}">
      <tr><td>${rs.SicknessName}</td></tr>
</c:forEach>
or
<%
  java.sql.ResultSet rs=idSicknessInfo.getSicknessResult(idSicknessInfo);
%>
<c:set var="rs" value="${rs}"/>
<c:forEach var="rs" items="${rs}">
      <tr><td>${rs.getString("SicknessName")}</td></tr>
</c:forEach>

can not get data,why?

0
 
LVL 35

Expert Comment

by:TimYates
ID: 11760628
<%
  java.sql.ResultSet rs=idSicknessInfo.getSicknessResult(idSicknessInfo);
  while( rs.next() )
  {
%>
     <tr><td><%= rs.getString("SicknessName") %></td></tr>
<%
  }
%>

I don't think the "forEach" tag will call "next()", and iterate smoothly through the result set...  I don't really use JSTL, so I may be wrong...
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 20 total points
ID: 11764047
You could try this.

<%
  java.sql.ResultSet rs=idSicknessInfo.getSicknessResult(idSicknessInfo);
  javax.servlet.jsp.jstl.sql.Result  result = javax.servlet.jsp.jstl.sql.ResultSupport.toResult(rs);
%>
<c:set var="result" value="<%=result%>"/>
<c:forEach var="row" items="${result.rows}">
     <tr><td>${row.SicknessName}</td></tr>
</c:forEach>
0
 

Author Comment

by:jbas
ID: 11768683
thanks to TimYates  and rrz@871311 ,now i can work continue,best regard for you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache-Tomcat Single Sign On with NTLM/Kerberos on Windows 2008R2 3 255
String format issue 13 93
getting param value 7 59
dynamic reloading of jsp in jetty 2 121
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question