Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 11th, 2005, 10: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?

Reply With Quote
  #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

Reply With Quote
  #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";
      }
  %>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination with checkboxes argan Pro JSP 2 November 27th, 2008 11:48 PM
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



All times are GMT -4. The time now is 04:04 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.