Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

can experts give me a demo use Pager Tag Library.

Posted on 2004-08-09
8
732 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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