/* * Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package egovframework.rte.ptl.mvc.tags.ui.pagination; import java.text.MessageFormat; /** * AbstractPaginationRenderer.java * <p><b>NOTE:</b><pre> 인터페이스 PaginationRenderer의 구현 추상클래스. * 기본적인 페이징 기능이 구현되어 있으며, 화면에서 아래와 같이 display 된다. * * [처음][이전] 1 2 3 4 5 6 7 8 [다음][마지막] * * 클래스 변수들이 각 element와 매핑이 되는데, * firstPageLabel = [처음] * previousPageLabel = [이전] * currentPageLabel = 현재 페이지 번호 * otherPageLabel = 현재 페이지를 제외한 페이지 번호 * nextPageLabel = [다음] * lastPageLabel = [마지막] * * 클래스 변수값을 AbstractPaginationRenderer를 상속받은 하위 클래스에서 주게 되면, * 페이징 포맷만 프로젝트 UI에 맞춰 커스터마이징 할 수 있다. * 자세한 사항은 개발자 메뉴얼의 개발프레임워크 실행환경/화면처리/MVC/View/Pagination Tag를 참고하라. * </pre> * @author 실행환경 개발팀 함철 * @since 2009.06.01 * @version 1.0 * @see * * <pre> * << 개정이력(Modification Information) >> * * 수정일 수정자 수정내용 * ------- -------- --------------------------- * 2009.05.30 함철 최초 생성 * * </pre> */ public abstract class AbstractPaginationRenderer implements PaginationRenderer{ public String firstPageLabel; public String previousPageLabel; public String currentPageLabel; public String otherPageLabel; public String nextPageLabel; public String lastPageLabel; public String renderPagination(PaginationInfo paginationInfo,String jsFunction){ StringBuffer strBuff = new StringBuffer(); int firstPageNo = paginationInfo.getFirstPageNo(); int firstPageNoOnPageList = paginationInfo.getFirstPageNoOnPageList(); int totalPageCount = paginationInfo.getTotalPageCount(); int pageSize = paginationInfo.getPageSize(); int lastPageNoOnPageList = paginationInfo.getLastPageNoOnPageList(); int currentPageNo = paginationInfo.getCurrentPageNo(); int lastPageNo = paginationInfo.getLastPageNo(); if(totalPageCount > pageSize){ if(firstPageNoOnPageList > pageSize){ strBuff.append(MessageFormat.format(firstPageLabel,new Object[]{jsFunction,Integer.toString(firstPageNo)})); strBuff.append(MessageFormat.format(previousPageLabel,new Object[]{jsFunction,Integer.toString(firstPageNoOnPageList-1)})); }else{ strBuff.append(MessageFormat.format(firstPageLabel,new Object[]{jsFunction,Integer.toString(firstPageNo)})); strBuff.append(MessageFormat.format(previousPageLabel,new Object[]{jsFunction,Integer.toString(firstPageNo)})); } } for(int i=firstPageNoOnPageList;i<=lastPageNoOnPageList;i++){ if(i==currentPageNo){ strBuff.append(MessageFormat.format(currentPageLabel,new Object[]{Integer.toString(i)})); }else{ strBuff.append(MessageFormat.format(otherPageLabel,new Object[]{jsFunction,Integer.toString(i),Integer.toString(i)})); } } if(totalPageCount > pageSize){ if(lastPageNoOnPageList < totalPageCount){ strBuff.append(MessageFormat.format(nextPageLabel,new Object[]{jsFunction,Integer.toString(firstPageNoOnPageList+pageSize)})); strBuff.append(MessageFormat.format(lastPageLabel,new Object[]{jsFunction,Integer.toString(lastPageNo)})); }else{ strBuff.append(MessageFormat.format(nextPageLabel,new Object[]{jsFunction,Integer.toString(lastPageNo)})); strBuff.append(MessageFormat.format(lastPageLabel,new Object[]{jsFunction,Integer.toString(lastPageNo)})); } } return strBuff.toString(); } }