<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 241,  comments - 116,  trackbacks - 0
    分頁(yè)處理、儲(chǔ)存工具類(lèi)。
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;

    /**
     * 儲(chǔ)存分頁(yè)處理工具類(lèi) 在調(diào)用此類(lèi)的方法之前需設(shè)置總頁(yè)數(shù)(即得先從數(shù)據(jù)庫(kù)查詢(xún)到相應(yīng)數(shù)據(jù)的數(shù)據(jù)量)
     *
     * @author ahomeeye
     * @version 1.0
     */
    public class Pagination implements Serializable {

        private static final long serialVersionUID = 1L;
        public final static String FIRST_ACTION = "First"; // 執(zhí)行跳到第一頁(yè)操作
        public final static String NEXT_ACTION = "Next"; // 執(zhí)行跳到下一頁(yè)操作韓國(guó)女裝
        public final static String PREVIO_ACTION = "Prev"; // 執(zhí)行跳到上一頁(yè)操作
        public final static String LAST_ACTION = "Last"; // 執(zhí)行跳到最一頁(yè)操作
        public final static String CURRENT_TAG = "currentPage"; // 當(dāng)前頁(yè)數(shù)
        public final static String PAGINATION_ACTION_TAG = "paginationAction"; // 緩存操作
        public final static String GOTO_PAGE_ACTION = "gotoPage"; // 執(zhí)行跳到指定的某一頁(yè)操作
        public final static String PAGES_GOTO = "pageSelect"; // 執(zhí)行g(shù)oto操作時(shí),用戶所指定的頁(yè)數(shù)
        http://hanguonvzhuang.blogcn.com/articles/2011/09/page/2
        private int start; // start表示當(dāng)前頁(yè)開(kāi)始的記錄數(shù),start=每頁(yè)行數(shù)*(當(dāng)前頁(yè)數(shù)-1)
        private int end; // 當(dāng)前頁(yè)結(jié)束的記錄行數(shù)
        private int totalCount; // 總行數(shù)
        private int rowsPerPage = 15; // 每頁(yè)行數(shù),默認(rèn)15
        private int currentPage; // 當(dāng)前頁(yè)數(shù)
        private int pageListSize = 9;// 頁(yè)碼列表大小,默認(rèn)9
        private List<Integer> pageNumList = new ArrayList<Integer>();

        public Pagination() {
            start = 0;
            end = 0;
            currentPage = 1;
            this.totalCount = 0;
        }

        public Pagination(int totalCount) {
            start = 0;
            end = 0;
            currentPage = 1;
            this.totalCount = totalCount;
        }

        public Pagination(int totalCount, int numPerPage) {
            start = 0;
            end = 0;
            this.totalCount = totalCount;
            currentPage = 1;
            if (numPerPage > 0) {
                rowsPerPage = numPerPage;
            }
        }

        /**
         * 執(zhí)行翻頁(yè)動(dòng)作
         *
         * @param currentPage
         *            要翻到的目標(biāo)頁(yè)碼
         * @return 返回翻頁(yè)對(duì)象
         */
        public Pagination doPagination(int currentPage) {
            gotoPage(currentPage);
            return this;
        }

        // 設(shè)置起始數(shù)
        public int getStart() {
            start = rowsPerPage * (currentPage - 1);
            return start;
        }

        // 得到起始數(shù)
        public void setStart(int start) {
            if (start < 0) {
                this.start = 0;
            } else if (start >= this.totalCount) {
                this.start = this.totalCount - 1;
            } else {
                this.start = start;
            }
        }

        // 設(shè)置當(dāng)前頁(yè)的最后一行的在總記錄中的順序(從0開(kāi)始)
        public void setEnd(int end) {
            this.end = end;
        }

        // 得到當(dāng)前頁(yè)的最后一行的在總記錄中的順序(從0開(kāi)始)
        public int getEnd() {
            if (rowsPerPage * currentPage > this.totalCount) {
                end = this.totalCount - 1;
            } else {
                end = rowsPerPage * currentPage - 1;
            }
            return end;
        }

        // 以下4個(gè)方法供控制器(struts)調(diào)用

        // 判斷能否到第一頁(yè);只要能到上一頁(yè),肯定就有第一頁(yè)
        public boolean firstEnable() {
            return previousEnable();
        }

        // 判斷能否到上一頁(yè)
        public boolean previousEnable() {
            return currentPage > 1;// 只要不是第一頁(yè),就能到上一頁(yè)
        }

        // 判斷能否到下一頁(yè)
        public boolean nextEnable() {
            return currentPage * rowsPerPage < this.totalCount;
        }

        // 判斷能否到最后一頁(yè);只要有下一頁(yè),就肯定有最后一頁(yè).
        public boolean lastEnable() {
            return nextEnable();
        }

        // 跳到第一頁(yè)
        public void firstPage() {
            currentPage = 1;
        }

        // 跳到上一頁(yè)
        public void previousPage(int cPage) {
            currentPage = (cPage - 1) > 0 ? (cPage - 1) : 1;
        }

        // 跳到下一頁(yè)
        public void nextPage(int cPage) {
            currentPage = cPage + 1;
            if (currentPage * rowsPerPage > this.totalCount) {
                lastPage();
            }
        }

        // 跳到最后一頁(yè)
        public void lastPage() {
            if (this.totalCount % rowsPerPage == 0) {
                currentPage = this.totalCount / rowsPerPage;
            } else {
                currentPage = this.totalCount / rowsPerPage + 1;
            }
        }

        // 跳到指定的某一頁(yè)
        public void gotoPage(int pageNumber) {
            if (pageNumber <= 1) {
                currentPage = 1;
            } else if (getTotalCount() < this.getRowsPerPage()) {
                currentPage = 1;
            } else if (pageNumber * rowsPerPage >= this.totalCount) {
                lastPage();
            } else {
                currentPage = pageNumber;
            }
        }

        // 設(shè)置總行數(shù)
        public void setTotalCount(int totalCount) {
            this.totalCount = totalCount;
        }

        // 得到總行數(shù)
        public int getTotalCount() {
            return totalCount;
        }

        // 設(shè)置每頁(yè)行數(shù)
        public void setRowsPerPage(int rowsPerPage) {
            this.rowsPerPage = rowsPerPage;
        }

        // 得到每頁(yè)行數(shù)
        public int getRowsPerPage() {
            return rowsPerPage;
        }

        // 得到總頁(yè)數(shù)
        public int getPages() {
            if (this.totalCount % rowsPerPage == 0)
                return this.totalCount / rowsPerPage;
            else
                return this.totalCount / rowsPerPage + 1;
        }

        // 得到當(dāng)前頁(yè)數(shù)
        public int getCurrentPage() {
            return currentPage;
        }

        // 設(shè)置當(dāng)前頁(yè)數(shù)
        public void setCurrentPage(int currentPage) {
            this.currentPage = currentPage;
        }

        public int getPageListSize() {
            return pageListSize;
        }

        // 設(shè)置頁(yè)碼列表大小
        public void setPageListSize(int pageListSize) {
            this.pageListSize = pageListSize;
        }

        // 得到頁(yè)面列表
        public List<Integer> getPageNumList() {
            this.pageNumList.removeAll(this.pageNumList);// 設(shè)置之前先清空
            int totalPage = getPages();
            if (totalPage > this.pageListSize) {
                int halfSize = this.pageListSize / 2;
                int first = 1;
                int end = 1;
                if (this.currentPage - halfSize < 1) { // 當(dāng)前頁(yè)靠近最小數(shù)1
                    first = 1;
                    end = this.pageListSize;
                } else if (totalPage - this.currentPage < halfSize) { // 當(dāng)前頁(yè)靠近最大數(shù)
                    first = totalPage - this.pageListSize + 1;
                    end = totalPage;
                } else {
                    first = this.currentPage - halfSize;
                    end = this.currentPage + halfSize;
                }
                for (int i = first; i <= end; i++) {
                    this.pageNumList.add(i);
                }
            } else {
                for (int i = 0; i < totalPage; i++) {
                    this.pageNumList.add(i + 1);
                }
            }

            return pageNumList;
        }
    }
    posted on 2011-09-19 11:21 墻頭草 閱讀(3469) 評(píng)論(1)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    人人游戲網(wǎng) 軟件開(kāi)發(fā)網(wǎng) 貨運(yùn)專(zhuān)家
    主站蜘蛛池模板: 亚洲偷偷自拍高清| 大片免费观看92在线视频线视频| 99久久综合国产精品免费| 亚洲AV无码一区二区三区牲色| 亚洲一区二区三区乱码A| 最近免费最新高清中文字幕韩国| 无码人妻一区二区三区免费手机| 久久亚洲精品11p| 亚洲第一AAAAA片| 国外成人免费高清激情视频| 亚洲精品一卡2卡3卡三卡四卡| 香蕉视频在线观看免费国产婷婷| 中文字幕无码毛片免费看| 国产免费av片在线播放| 精品免费tv久久久久久久| 亚洲欧美日韩一区二区三区| 亚洲成AV人片在| 四虎影视在线永久免费观看| 1000部无遮挡拍拍拍免费视频观看 | 亚洲日韩精品国产3区| 亚洲精品国产字幕久久不卡 | 最新仑乱免费视频| 中文永久免费观看网站| 亚洲精品一卡2卡3卡四卡乱码| 亚洲av无码一区二区三区乱子伦| 日韩在线看片免费人成视频播放 | 国产精品亚洲成在人线| 日韩电影免费在线观看视频| 99在线观看免费视频| 一区二区三区免费视频播放器| 亚洲午夜福利在线视频| 久久久久亚洲av无码专区喷水| 亚洲福利视频一区二区| 日日狠狠久久偷偷色综合免费 | 国产精品免费看久久久 | 亚洲综合免费视频| 韩国免费A级毛片久久| 羞羞漫画页面免费入口欢迎你| 亚洲性无码AV中文字幕| 亚洲国产精品无码久久久| 亚洲AV午夜福利精品一区二区|