您的位置:首页 >> Web开发 >> JSP技术 >> 正文
RSS
 

实现jsp页面得分页显示功能方案

http://www.rdxx.com 02年04月12日 11:23 互联网 我要投稿

关键词: 页面 , 显示 , 功能 , 分页 , 方案 , JSP

实现jsp页面得分页显示功能方案:

com.cn.page.PageBean.java 用于控制分页的情况和数据的处理的。

com.cn.page.PageView.java 用于在jsp页面中显示表单的。

 

//接口的定义:

public interface ContactBean {

  public int getAvailableCount()throws Exception;

  public int getAvailableCount(int id)throws Exception;

  public PageBean listData(String page)throws Exception ;

  public PageBean listData(String page,int id)throws Exception ;

  public Collection getResult()throws Exception;

}

//pageBean的定义:

public class PageBean {

  public int curPage;//当前的页值。

  public int maxPage;//最大的页数。

  public int maxRowCount;//最大的行数。

  public static int rowsPerPage=10; //控制分页的行数。

  public java.util.Collection data; //所要显示的数据的集合。

  public PageBean() {

  }

  public void countMaxPage(){

    if(this.maxRowCount%this.rowsPerPage==0){

      this.maxPage=this.maxRowCount/this.rowsPerPage;

    }else{

      this.maxPage=this.maxRowCount/this.rowsPerPage+1;

    }

  }

  public Collection getResult(){

    return this.data;

  }

  public PageBean(ContactAdapter bean,int id)throws Exception{

    this.maxRowCount=bean.getAvailableCount(id);

    if(maxRowCount==0)

      maxRowCount=1;

    System.out.println(maxRowCount);

    this.data=bean.getResult();

    this.countMaxPage();

  }

  public PageBean(ContactAdapter bean)throws Exception{

    this.maxRowCount=bean.getAvailableCount();

    this.data=bean.getResult();

    this.countMaxPage();

  }

}

//ContactBean接口进行adapter模式的封装。方便实用。

public class ContactAdapter implements ContactBean{

  public ContactAdapter() {  }

  public int getAvailableCount()throws Exception{

    return 0;

  }

  public int getAvailableCount(int id)throws Exception{

    return 0;

  }

  public PageBean listData(String page)throws Exception {

    return null;

  }

  public PageBean listData(String page,int id)throws Exception {

    return null;

  }

  public Collection getResult()throws Exception{

    return null;

  }

}

 

 

在使用中你可以实现com.cn.interfaces.ContactBean 或继承 com.cn.interfaces.ContactAdapter都可以。

实现方法:

                            实现一:其中不需要键入任何参数。

public int getAvailableCount()throws Exception;

                           

9 7 3 1 2 3 4 8 :

 
 
标签: 页面 , 显示 , 功能 , 分页 , 方案 , JSP 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站