?? xpage.java
字號:
package com.yuanchung.sales.util;
import java.util.ArrayList;
import java.util.Collection;
public class XPage {
private int currentPage; //當前頁碼
private int pageCount;//每頁記錄數
private String path;//查詢路徑
private int allCount;//總記錄數
private Collection items;//查詢的數據集
private Collection currentItems;//當前頁結果集
private String pageBar;
public Collection getCurrentItems() {
return currentItems;
}
public void setCurrentItems(int currentPage) {
Collection currentItems = null;
this.currentPage = currentPage;
currentItems = new ArrayList();
ArrayList al = (ArrayList)items;
if(currentPage < (allCount / pageCount) + 1){
for(int i = (currentPage - 1) * pageCount; i < currentPage * this.pageCount; i++){
currentItems.add(al.get(i));
}
}else{
for(int i = (currentPage - 1) * pageCount; i < allCount; i++){
currentItems.add(al.get(i));
}
}
this.currentItems = currentItems;
}
public XPage(){}
public XPage(String path, int allCount, int currentPage, int pageCount, Collection items ){
this.path = path;
this.allCount = allCount;
this.currentPage = currentPage;
this.pageCount = pageCount;
this.items = items;
}
public int getAllCount() {
return allCount;
}
public void setAllCount(int allCount) {
this.allCount = allCount;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int count) {
this.pageCount = count;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public Collection getItems() {
return items;
}
public void setItems(Collection items) {
this.items = items;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public int getAllPage(){
if(this.allCount % this.pageCount == 0){
return (this.allCount)/this.pageCount;
}else{
return (this.allCount)/this.pageCount+1;
}
}
public void setPageBar(){
StringBuffer bar = new StringBuffer();
bar.append("<%@ page language='java' pageEncoding='UTF-8'%>");
bar.append("<div class='tableHead'>");
if(this.currentPage<=1){
bar.append("首頁 上頁 ");
}else{
bar.append("<a href=\""+path+"¤tPage=1\">首頁</a> ");
bar.append("<a href=\""+path+"¤tPage="+(this.currentPage-1)+"\">上頁</a> ");
}
bar.append(" <select name=\"xx\" onchange=\"forward(this.value)\">");
for(int i=1;i<=this.getAllPage();i++){
if(i==this.currentPage){
bar.append("<option value='"+i+"' selected>"+i+"/"+this.getAllPage()+"</option>");
}else{
bar.append("<option value='"+i+"'>"+i+"/"+this.getAllPage()+"</option>");
}
}
bar.append("</select></span> ");
if(this.currentPage>=this.getAllPage()){
bar.append("下頁 尾頁");
}else{
bar.append("<a href=\""+path+"¤tPage="+(this.currentPage+1)+"\">下頁</a> ");
bar.append("<a href=\""+path+"¤tPage="+(this.getAllPage())+"\">尾頁</a>");
}
bar.append("<span align=\"left\" style='margin-left:10px'>每頁"+this.pageCount+"條/共"+this.getAllPage()+"頁 共"+this.allCount+"條</span></div>");
bar.append("<script>");
bar.append("function forward(page){");
bar.append(" location.href='"+path+"¤tPage='+page;");
bar.append("}");
bar.append("</script>");
this.pageBar = bar.toString();
}
public String getPageBar(){
return this.pageBar;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -