Solved

can experts give me a demo use Pager Tag Library.

Posted on 2004-08-09
8
734 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
[X]
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
  • 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
Technology Partners: 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
report generation frameworks 1 73
lessBy10  challenge 15 97
Java Script nested call 3 91
how to hide hide popup page refresh second time? 10 183
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…

734 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