Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 11th, 2005, 11:25 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Regornil
Default pagination

hey guys..new prob here.gotta do pagination for return results..like displayin 5 out of 100 results per page.anione can help?

  #2 (permalink)  
Old May 1st, 2005, 11:43 AM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello there,
I would suggest you to use Database (SQL) to do this job of pagination. What's the database you are using?
I am sure rownum field in SQL should do the trick.
You could also use rowset of Java. But this really sucks... Not like the Recordset of ADO...

regds,
Babloo

  #3 (permalink)  
Old May 31st, 2005, 06:10 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is what I did for 20 results per page, and control the page by pagenum buttons.

First, get all of your search reasult, then, consider the following code:

Code:
<%
          iii18Class.getQuery("III18Class", "MemberPhoto", "MemberDetail", "MemberAdvancedDetail");
          Vector details = (Vector) iii18Class.getDetails("III18ClassContent");
          String pageNums = (String)application.getAttribute("pageNum");
          int pageCount = details.size() / 20 + 1;

          if(pageNums == null ){
            pageNums = "1";
          }
          int pNo = Integer.parseInt(pageNums);

          out.print("<input class=pagenum type=submit name=pageBtn value=" + 1 + ">" + "...");

          if (details.size() <= 20) {
            out.print("<input class=pagenum type=submit name=pageBtn value=" + 1 + ">");
          }
          if (details.size() > 20) {
            if(pNo > 4){
              if(pNo < details.size() / 20 + 1){
                for (int i = pNo - 3; i <= pNo + 1; i++) {
                  out.print("<input class=pagenum type=submit name=pageBtn value=" + i + ">");
                }
              }
              else if(pNo == pageCount){
                for (int i = pNo - 4; i < pNo + 1; i++) {
                  out.print("<input class=pagenum type=submit name=pageBtn value=" + i + ">");
                }
              }
            }
            else{
              if(pageCount < 5){
                for (int i = 1; i <= pageCount; i++) {
                  out.print("<input class=pagenum type=submit name=pageBtn value=" + i + ">");
                }
              }
              else if(pageCount >= 5){
                for (int i = 1; i <= 5; i++) {
                  out.print("<input class=pagenum type=submit name=pageBtn value=" + i + ">");
                }
              }
            }
          }
          out.print("..." + "<input class=pagenum type=submit name=pageBtn value=" + pageCount + ">");
        %>
Code:
<%
    request.setCharacterEncoding("big5");
    String pageBtn = (String) request.getParameter("pageBtn");
    session.setAttribute("pages", pageBtn);
    String color = "";
    int pageNo = 0;
    if (pageBtn == null) {
      pageNo = 1;
    }
    else {
      pageNo = Integer.parseInt(pageBtn);
    }
    for (int i = (pageNo - 1 + (pageNo - 1)) * 10; i <= ((pageNo * 2) - 1) * 10 + 9; i++) {
      String[] dat = new String[6];
      if (i >= details.size()) {
        return;
      }
      dat = (String[]) details.elementAt(i);
      if (i % 2 == 0) {
        color = "t_one";
      }
      else {
        color = "t_two";
      }
  %>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination with checkboxes argan Pro JSP 2 November 28th, 2008 12:48 AM
Grouping and Pagination jayne XSLT 13 June 6th, 2007 01:52 AM
pagination problem solos XSLT 1 April 4th, 2007 05:40 PM
Please.....Pagination junemo PHP Databases 2 September 25th, 2004 01:14 PM
pagination junemo Oracle 0 July 1st, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.