Solved

can experts give me a demo use Pager Tag Library.

Posted on 2004-08-09
8
727 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

20 Experts available now in Live!

Get 1:1 Help Now