본문 바로가기
Web Program/Java Lecture

게시판 리스트의 page class

by 현이빈이 2008. 8. 13.
반응형

package jspmall;

import java.lang.*;
import java.util.*;
import java.text.*;

public class PageClass{

public void PageClass(){

}

//ex) BlockPagin("aaa.asp", "user_id=aaa", page, 10, 2, "img/prev.gif", "img/next.gif")
//msgmeet_list.asp, idx=1&msg_flag=i_location, 1, 10, 3, img/btn_prev.gif, img/btn_next.gif
public String getBlockPaging(String url, String param, int cpage, int blockPage, int totalPage, String prev_img, String next_img) {
String strBuffer="";
int intTemp=0;
String strPrevImgTag="";
String strNextImgTag="";

int intLoop = 0;

intTemp = ((cpage-1) / blockPage) * blockPage + 1;

strPrevImgTag = "<img src='" + prev_img + "' border=0 alt='이전" + Integer.toString(blockPage) + "개' align=absmiddle>";
strNextImgTag = "<img src='" + next_img + "' border=0 alt='다음" + Integer.toString(blockPage) + "개' align=absmiddle>";

if (intTemp==1) {
strBuffer = strPrevImgTag + "&nbsp;&nbsp;";
} else {
strBuffer = "<a href='" + url + "?cpage=" + Integer.toString(intTemp - blockPage) + "&" + param + "'>" + strPrevImgTag + "</a>&nbsp;&nbsp;";
}

intLoop = 1;

while((intLoop <= blockPage) && (intTemp <= totalPage)) {
if (intTemp==cpage) {
strBuffer = strBuffer + " <strong><font face='굴림' size='2' color='#FF6600'>" + Integer.toString(intTemp) + "</font></strong> ";
}else {
strBuffer = strBuffer + " <strong><a href='" + url + "?cpage=" + Integer.toString(intTemp) + "&" + param + "'>" + Integer.toString(intTemp) + "</a></strong> ";
}

//if(intLoop < intTemp) { strBuffer = strBuffer + " | ";}
intTemp++;
intLoop++;
}

if (intTemp>totalPage) {
strBuffer = strBuffer + "&nbsp;&nbsp;" + strNextImgTag;
}else {
strBuffer = strBuffer + "&nbsp;&nbsp;<a href='" + url + "?cpage=" + Integer.toString(intTemp) + "&" + param + "'>" + strNextImgTag + "</a>";
}

return strBuffer;

}


}

반응형