1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| package com.itwillbs.domain;
public class PageMaker { private int totalCount; private int startPage; private int endPage; private boolean prev; private boolean next; private Criteria cri; private int displayPageNum = 10;
public PageMaker() {} public PageMaker(int totalCount, int startPage, int endPage, boolean prev, boolean next, Criteria cri, int displayPageNum) { super(); this.totalCount = totalCount; this.startPage = startPage; this.endPage = endPage; this.prev = prev; this.next = next; this.cri = cri; this.displayPageNum = displayPageNum; }
public int getTotalCount() { return totalCount; }
public void setTotalCount(int totalCount) { this.totalCount = totalCount; System.out.println("DB에서 총 글의 개수를 계산"); calcDate(); } private void calcDate() { endPage = (int) (Math.ceil(cri.getPage()/(double)displayPageNum) * displayPageNum); startPage = (endPage - displayPageNum) +1; int tempEndPage = (int) (Math.ceil(totalCount/(double)cri.getPageSize())); if(endPage > tempEndPage) endPage = tempEndPage; prev = (startPage == 1? false:true); next = (endPage * cri.getPageSize() >= totalCount? false:true); System.out.println("페이징처리정보 계산"); }
public int getStartPage() { return startPage; }
public void setStartPage(int startPage) { this.startPage = startPage; }
public int getEndPage() { return endPage; }
public void setEndPage(int endPage) { this.endPage = endPage; }
public boolean isPrev() { return prev; }
public void setPrev(boolean prev) { this.prev = prev; }
public boolean isNext() { return next; }
public void setNext(boolean next) { this.next = next; }
public Criteria getCri() { return cri; }
public void setCri(Criteria cri) { this.cri = cri; }
public int getDisplayPageNum() { return displayPageNum; }
public void setDisplayPageNum(int displayPageNum) { this.displayPageNum = displayPageNum; } @Override public String toString() { return "PageMaker [totalCount=" + totalCount + ", startPage=" + startPage + ", endPage=" + endPage + ", prev=" + prev + ", next=" + next + ", cri=" + cri + ", displayPageNum=" + displayPageNum + "]"; } }
|