这个是引用的文件
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date: 2006-8-10 11:35:20
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: MultiPage.java
package com.cdx.share;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
// Referenced classes of package com.cdx.share:
// ConfigManager
public class MultiPage
{
public MultiPage()
{
iTotalSize = 0;
iPageSize = 0;
iPage = 1;
iRowStart = 0;
iRowEnd = 0;
iPageCount = 2;
htUserArea = new Hashtable();
}
public static MultiPage getInstance(HttpServletRequest request)
throws Exception
{
MultiPage cMultiPage;
Object objMultiPage = request.getSession().getAttribute("cMultiPage");
if(objMultiPage == null)
{
cMultiPage = new MultiPage();
request.getSession().setAttribute("cMultiPage", cMultiPage);
} else
{
cMultiPage = (MultiPage)objMultiPage;
}
if(cMultiPage.iPageSize == 0)
{
String SiPageSize = ConfigManager.getValue("PerPageRecordCount");
if(SiPageSize.equals("0"))
SiPageSize = "20";
cMultiPage.iPageSize = Integer.parseInt(SiPageSize);
}
for(Enumeration eKey = cMultiPage.htUserArea.keys(); eKey.hasMoreElements();)
{
String sKey = eKey.nextElement().toString();
Object obj = request.getAttribute(sKey);
if(obj == null)
{
request.setAttribute(sKey, cMultiPage.htUserArea.get(sKey));
} else
{
request.setAttribute(sKey, obj);
cMultiPage.iPage = 1;
}
}
String SiPage = request.getParameter("iPagePara");
if(SiPage == null || SiPage.equals(""))
SiPage = "1";
cMultiPage.iPage = Integer.parseInt(SiPage);
String SiPageSize = request.getParameter("iPageSizePara");
if(SiPageSize != null)
{
cMultiPage.iPageSize = Integer.parseInt(SiPageSize);
int iPages = cMultiPage.iTotalSize / cMultiPage.iPageSize;
if(cMultiPage.iTotalSize % cMultiPage.iPageSize > 0)
iPages++;
if(cMultiPage.iPage > iPages)
cMultiPage.iPage = iPages;
if(cMultiPage.iPage == 0)
cMultiPage.iPage = 1;
}
return cMultiPage;
Exception e;
e;
e.printStackTrace(System.out);
throw e;
}
public String getNavigation(String sURL)
throws Exception
{
return getNavigation(sURL, "");
}
public String getNavigation(String sURL, String sPara)
throws Exception
{
String sReturn;
int iPages = iTotalSize / iPageSize;
if(iTotalSize % iPageSize > 0)
iPages++;
int iPageCountS = iPage - iPageCount;
int iPageCountE = iPage + iPageCount;
if(iPageCountS < iPageCount)
iPageCountE = 2 * iPageCount + 1;
if(iPageCountE > iPages)
iPageCountS = iPages - 2 * iPageCount;
if(iPageCountS < 1)
iPageCountS = 1;
if(iPageCountE > iPages)
iPageCountE = iPages;
sReturn = "<script type=text/javascript>\r\n";
sReturn = sReturn + "function PageShowPage(iPagePara)\r\n";
sReturn = sReturn + "{\r\n";
sReturn = sReturn + " var obj=0; var iPageSizeParaValue=20;\r\n";
sReturn = sReturn + " try{obj=iPageSizePara;}catch(pe){ for(var m=0;m<document.forms.length;m++){ try{obj=document.forms[m]['iPageSizePara'];if(typeof obj == 'object') break;}catch(pe2){}; } };\r\n";
sReturn = sReturn + " if(obj!=0) iPageSizeParaValue=obj.value;\r\n";
sReturn = sReturn + " if(iPageSizeParaValue.length==0)\r\n";
sReturn = sReturn + " {\r\n";
sReturn = sReturn + " alert('\u8BF7\u8F93\u5165\u6BCF\u9875\u663E\u793A\u6570!'); obj.value='" + iPageSize + "';if(obj!=0) obj.focus();\r\n";
sReturn = sReturn + " }\r\n";
sReturn = sReturn + " else \r\n";
sReturn = sReturn + " {";
sReturn = sReturn + " fm.action= '" + sURL + "' ; ";
sReturn = sReturn + " fm.iPagePara.value= iPagePara ;";
sReturn = sReturn + " fm.iPageSizePara.value= iPageSizeParaValue ;";
sReturn = sReturn + " fm.submit() ;";
sReturn = sReturn + " }";
sReturn = sReturn + "}\r\n";
sReturn = sReturn + "function PageCheckNumber(obj) {var varNumbers='0123456789'; for(var i=0;i<obj.value.length;i++){if(obj.value==0 || varNumbers.indexOf(obj.value.charAt(i))==-1){if(obj.name=='iPageSizePara') obj.value='" + iPageSize + "'; else obj.value='" + iPage + "'; alert('\u8BF7\u8F93\u5165\u6B63\u6574\u6570!'); obj.focus(); return false;} } return true;}\r\n";
sReturn = sReturn + "function goPageSize()\r\n";
sReturn = sReturn + "{\r\n";
sReturn = sReturn + " var obj=0; var iPageParaValue=1;\r\n";
sReturn = sReturn + " try{obj=iPagePara;}catch(pe){for(var m=0;m<document.forms.length;m++){try{obj=document.forms[m]['iPagePara'];if(typeof obj == 'object') break;}catch(pe2){};}};\r\n";
sReturn = sReturn + " if(obj!=0) iPageParaValue=obj.value;\r\n";
sReturn = sReturn + " if(iPageParaValue=='') iPageParaValue='" + iPage + "'\r\n";
sReturn = sReturn + " if(iPageParaValue>" + iPages + " || iPageParaValue.length==0)\r\n";
sReturn = sReturn + " {\r\n";
sReturn = sReturn + " alert('\u8BF7\u8F93\u5165\u6570\u5B57\uFF0C\u8303\u56F4\u4E3A: 1 \u5230 " + iPages + " !'); if(obj!=0) obj.focus();\r\n";
sReturn = sReturn + " }\r\n";
sReturn = sReturn + " else\r\n";
sReturn = sReturn + " PageShowPage(iPageParaValue);\r\n";
sReturn = sReturn + "}\r\n";
sReturn = sReturn + "function PageKeyEnterPage(obj) {if(event.keyCode==13) {if(PageCheckNumber(obj) && obj.value!=\"\") goPageSize(); event.cancelBubble=true; event.returnValue=false;} }\r\n";
sReturn = sReturn + "function PageKeyEnterSize(obj) {if(event.keyCode==13) {if(PageCheckNumber(obj) && obj.value!=\"\") goPageSize(); event.cancelBubble=true; event.returnValue=false;} }\r\n";
sReturn = sReturn + "function PageGoPage_onClick() {var iPageParaValue=0;var obj=0; try{iPageParaValue=iPagePara.value;obj=iPagePara;}catch(pe){for(var m=0;m<document.forms.length;m++){try{iPageParaValue=document.forms[m][\"iPagePara\"].value;obj==document.forms[m][\"iPagePara\"];if(typeof obj == 'object') break;}catch(pe2){};}}; if(iPageParaValue!=0) goPageSize(); else if(obj!=0) obj.focus();}\r\n";
sReturn = sReturn + "</script>\r\n";
sReturn = sReturn + "|\u884C\u6570:";
sReturn = sReturn + iTotalSize + "|\u9875\u6570:";
sReturn = sReturn + iPage + "/" + iPages;
sReturn = sReturn + "| ";
if(iPage > 1)
{
sReturn = sReturn + "<a href='javascript: PageShowPage(" + 1 + ");'><font face='webdings'>9</font></a>";
sReturn = sReturn + "<a href='javascript: PageShowPage(" + (iPage - 1) + ");'><font face='webdings'>7</font></a>";
} else
{
sReturn = sReturn + "<font color=gray face='webdings'>9</font>";
sReturn = sReturn + "<font color=gray face='webdings'>7</font>";
}
sReturn = sReturn + " ";
for(int i = iPageCountS; i <= iPageCountE; i++)
{
if(iPage != i)
sReturn = sReturn + "<a href='javascript: PageShowPage(" + i + ");'>";
else
sReturn = sReturn + "<font color=red>";
sReturn = sReturn + i;
if(iPage != i)
sReturn = sReturn + "</a>\r\n";
else
sReturn = sReturn + "</font>\r\n";
if(i < iPageCountE)
sReturn = sReturn + " ";
}
if(iPage < iPages)
{
sReturn = sReturn + "<a href='javascript: PageShowPage(" + (iPage + 1) + ");'><font face='webdings'>8</font></a>";
sReturn = sReturn + "<a href='javascript: PageShowPage(" + iPages + ");'><font face='webdings'>:</font></a>";
} else
{
sReturn = sReturn + "<font color=gray face='webdings'>8</font>";
sReturn = sReturn + "<font color=gray face='webdings'>:</font>";
}
sReturn = sReturn + " |";
sReturn = sReturn + "<a id='PageGoPage' href='javascript: PageGoPage_onClick();'>\u8F6C\u5230</a>";
sReturn = sReturn + "<input name='iPagePara' type='text' style='BACKGROUND: transparence; BORDER-BOTTOM: #BBBBBB 1px solid; BORDER-LEFT: #BBBBBB 0px solid; BORDER-RIGHT: #BBBBBB 0px solid; BORDER-TOP: #BBBBBB 0px solid; FONT-SIZE: 12px; text-align:center' size=2 onkeydown='javascript: PageKeyEnterPage(this);' onblur='javascript: PageCheckNumber(this);event.returnValue=false;'>|";
sReturn = sReturn + "<a href='javascript: goPageSize();'>\u6BCF\u9875</a>";
sReturn = sReturn + "<input name='iPageSizePara' type='text' style='BACKGROUND: transparence; BORDER-BOTTOM: #BBBBBB 1px solid; BORDER-LEFT: #BBBBBB 0px solid; BORDER-RIGHT: #BBBBBB 0px solid; BORDER-TOP: #BBBBBB 0px solid; FONT-SIZE: 12px; text-align:center' size=2 onkeydown='javascript: PageKeyEnterSize(this);' onblur='javascript: PageCheckNumber(this);event.returnValue=false;' value='" + iPageSize + "'>|\r\n";
return sReturn;
Exception e;
e;
throw e;
}
public void setPageData(String key, Object obj)
{
htUserArea.put(key, obj);
}
public Object getPageData(String key)
{
return htUserArea.get(key);
}
public void setTotalSize(int iTotalSize)
{
this.iTotalSize = iTotalSize;
iRowStart = (iPage - 1) * iPageSize;
iRowEnd = iPage * iPageSize;
if(iRowEnd > this.iTotalSize)
iRowEnd = this.iTotalSize;
}
public int getPageSize()
{
return iPageSize;
}
public int getStartRowNo()
{
return iRowStart;
}
public int getEndRowNo()
{
return iRowEnd;
}
public int getTotalSize()
{
return iTotalSize;
}
public int getTotalPages()
{
if(iPageSize == 0)
iPageSize = 1;
int iPages = iTotalSize / iPageSize;
if(iTotalSize % iPageSize > 0)
iPages++;
return iPages;
}
private int iTotalSize;
private int iPageSize;
private int iPage;
private int iRowStart;
private int iRowEnd;
private int iPageCount;
private Hashtable htUserArea;
}