80 likes | 328 Views
Paging. 배상 준. 1.Paging 변수. int startPage =1; // 시작 페이지 || 현재 페이지 int curPage =1; // 현재 페이지의 첫글 번호 int curendPage =0; // 현재페이지의 끝글 번호 int countPerPage =1; // 페이지당 글 수 int totalCount =0; // 전체 글수 int totalPage =0; // 전체 페이지수 마지막 페이지 //------------ 여러 블록이라면
E N D
Paging 배상준
1.Paging 변수 • intstartPage=1; //시작 페이지 ||현재 페이지 • intcurPage=1; //현재 페이지의 첫글 번호 • intcurendPage=0; //현재페이지의 끝글 번호 • intcountPerPage=1; //페이지당 글 수 • inttotalCount=0; //전체 글수 • inttotalPage=0; //전체 페이지수 마지막 페이지 • //------------여러 블록이라면 • intstartBlock=1; //시작 블록 || 현재 블록 • intcountPerBlock=2; //한 블록 당 블록 수 • inttotalBlock=0; //전체 블록 수 • intcurBlockPage=0; //현재 블록의 첫 번째 페이지 • intcurendBlock=0; //현재 블록의 마지막 페이지 • intlastBlockPage=0; //마지막 페이지 =totalPage • intlastBlockStartPage=0; //전 블록의 시작 페이지
2. Paging without block-1 • startPage=3; //시작 페이지 • totalCount=28; //전체 글수 • countPerPage=5; //페이지당 글 수 일때 • curPage=(3-1)*5+1; //현재 페이지 첫글 번호 (startPage-1)*countPerPage+1 • curendPage=(3*5); //현재페이지의 끝글번호 (startPage*countPerPage) • totalPage=Math.ceil((28*1.0)/5) Math.ceil (totalCount*1.0)/totalCount)
2. Paging without block-2 • totalPage= (int)Math.ceil(totalCount*1.0/countPerPage); • curPage=totalPage==1?1: (startPage-1)*countPerPage+1; • curendPage=(totalPage!=startPage)? (startPage)*countPerPage: (totalCount%countPerPage==0?(startPage)*countPerPage:(curPage-1)+totalCount%countPerPage);
2-1.Paging 예 • public Vector<ChatterBoardDto> getChatBoardList(intsnum, intenums) { String strQuery = "select SEQCHAT, ID, TITLE, CONTENT, MDATE from ( select row_number() over (order by seqchatdesc) rn, SEQCHAT, ID, TITLE, CONTENT, MDATE from CHATTERBOARD) where rn between ? and ?
3. Paging with block-1 • startBlock=2; //시작 블록 totalCount=28; //전체 글수 • countPerBlock=2; • totalBlock=Math.ceil((6*1.0)/2)=3 (totalPage*1.0)/countPerBlock • curBlockPage=(2-1)*2+1=3; (startBlock-1)*countPerBlock+1 • curendBlock=(2*2)=4; (startBlock*countPerBlock) • lastBlockPage=Math.ceil((28*1.0)/5) (totalCount*1.0)/countPerPage; //마지막 페이지 • lastBlockStartPage=(2-2); (curBlockPage-countPerBlock)
3. Paging with block-2 • totalBlock=(int)Math.ceil(totalCount*1.0/(countPerPage*countPerBlock)); • curBlockPage=totalBlock==1?1: (startBlock-1)*countPerBlock+1; //마지막 블록 • lastBlockPage=(int)Math.ceil(totalCount*1.0/countPerPage); //totalPage //수정 2009.6.23 마지막 블록이라면 --- • curendBlock=(totalBlock!=(int)Math.ceil(curBlockPage*1.0/countPerBlock))?(startBlock*countPerBlock):lastBlockPage//총페이지수;
1 2 블록의 첫페이지=1, 마지막 페이지=2, 현재 블록=1 • 3 4 (2번째 블록-1)*한블록당 수(2)+1 =curBlockPage • 5 6 (3번째 블록)*한블록당수=curEndBlock • 페이지 수=6개 • 블록 수=3개 • 4 5 6 블록의 첫페이지=4, 마지막 페이지=6 • 7 8 9