⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paginationinfo.java

📁 这段代码是用struts实现的客户管理系统
💻 JAVA
字号:
package com.tarena.util;

import java.io.Serializable;

public class PaginationInfo implements Serializable {
    private static final long serialVersionUID = -1258628500927436850L;

    private int rowCount;

    private int currentPage;

    private int pageCount;

    private int rowPerPage = 10;

    private int startRow;

    public int getCurrentPage() {
        return currentPage;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void nextPage() {
        if (!isLastPage()) {
            currentPage = currentPage + 1;
            hadleStartRow();
        }
    }

    public void previousPage() {
        if (!isFirstPage()) {
            currentPage = currentPage - 1;
            hadleStartRow();
        }
    }

    public void firstPage() {
        currentPage = 1;
        hadleStartRow();
    }

    public void lastPage() {
        currentPage = pageCount;
        hadleStartRow();
    }

    public void gotoPage(int pageNo) {
        if (pageNo >= 1 && pageNo <= pageCount) {
            currentPage = pageNo;
            hadleStartRow();
        }
    }

    public boolean isFirstPage() {
        return (currentPage == 1);
    }

    public boolean isLastPage() {
        return (currentPage == pageCount);
    }

    public boolean hasNext() {
        return (currentPage != pageCount);
    }

    public boolean hasPrevious() {
        return (currentPage != 1);
    }

    public void setRowPerPage(int rowPerPage) {
        this.rowPerPage = rowPerPage;
    }

    public int getRowPerPage() {
        return rowPerPage;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
        currentPage = 1;
        pageCount = rowCount / rowPerPage;
        if (rowCount % rowPerPage != 0) {
            pageCount = pageCount + 1;
        }
        hadleStartRow();
    }

    public int getRowCount() {
        return rowCount;
    }

    private void hadleStartRow() {
        startRow = (currentPage - 1) * rowPerPage + 1;
    }
    
    public static void main(String[] args){
        PaginationInfo info = new PaginationInfo();
        info.setRowPerPage(3);
        info.setRowCount(7);
        System.out.println(info.getPageCount());
        System.out.println(info.getRowCount());
    }
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -