Solved

can experts give me a demo use Pager Tag Library.

Posted on 2004-08-09
8
729 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
library class in java 1 90
Spring Data jpa resouce mapping error "status":500,"error":"Internal Server Error", 3 285
maven project jars 7 50
spring example non maven 4 82
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now