java 实现分页的一种方式
2008-02-27 10:08
489 查看
利用向量实现分页的一种方式
view plaincopy to clipboardprint?
/** 当前页 */
private int nowPage = 1;
/** 最大页 */
private int maxPage = 0;
/** 显示数目 */
private String showRows = new String();
/**全部Vector */
private Vector allList = new Vector();
/** 每页Vector */
private Vector resultList = new Vector();
//改变页数,更新变量
public ChangePage(Vector pList, int pNowPage, String pShowRows) {
this.allList = pList;
//当前页
try {
this.nowPage = pNowPage;
if (this.nowPage == 0) {
this.nowPage = 1;
}
} catch (Exception e) {
this.nowPage = 1;
}
//显示数目
try {
if (!pShowRows.equals(Constants.SHOWALL)) {
if (Integer.parseInt(pShowRows)==0) {
this.showRows = Constants.SHOWALL;
} else {
this.showRows = pShowRows;
}
} else {
this.showRows = pShowRows;
}
} catch (Exception e) {
this.showRows = Constants.SHOWALL;
}
//最大页,每页
if (this.showRows.equals(Constants.SHOWALL)) {
//当前页
this.resultList = pList;
//最大页
this.maxPage = 1;
} else {
//显示数目
int counts = Integer.parseInt(this.showRows);
int tmpCount = 0;
Vector vAllPage = new Vector();
Vector vOnePage = new Vector();
for (int i=0; i<THIS.ALLLIST.SIZE(); (tmpCount if tmpCount++; { i++)>counts) {
vAllPage.add(vOnePage);
vOnePage = new Vector();
tmpCount = 1;
}
vOnePage.add(allList.get(i));
}
if (tmpCount<=counts) {
vAllPage.add(vOnePage);
}
this.maxPage = vAllPage.size();
if (this.nowPage>this.maxPage) {
this.nowPage = this.maxPage;
}
this.resultList = (Vector) vAllPage.get(this.nowPage-1);
}
}
view plaincopy to clipboardprint?
/** 当前页 */
private int nowPage = 1;
/** 最大页 */
private int maxPage = 0;
/** 显示数目 */
private String showRows = new String();
/**全部Vector */
private Vector allList = new Vector();
/** 每页Vector */
private Vector resultList = new Vector();
//改变页数,更新变量
public ChangePage(Vector pList, int pNowPage, String pShowRows) {
this.allList = pList;
//当前页
try {
this.nowPage = pNowPage;
if (this.nowPage == 0) {
this.nowPage = 1;
}
} catch (Exception e) {
this.nowPage = 1;
}
//显示数目
try {
if (!pShowRows.equals(Constants.SHOWALL)) {
if (Integer.parseInt(pShowRows)==0) {
this.showRows = Constants.SHOWALL;
} else {
this.showRows = pShowRows;
}
} else {
this.showRows = pShowRows;
}
} catch (Exception e) {
this.showRows = Constants.SHOWALL;
}
//最大页,每页
if (this.showRows.equals(Constants.SHOWALL)) {
//当前页
this.resultList = pList;
//最大页
this.maxPage = 1;
} else {
//显示数目
int counts = Integer.parseInt(this.showRows);
int tmpCount = 0;
Vector vAllPage = new Vector();
Vector vOnePage = new Vector();
for (int i=0; i<THIS.ALLLIST.SIZE(); (tmpCount if tmpCount++; { i++)>counts) {
vAllPage.add(vOnePage);
vOnePage = new Vector();
tmpCount = 1;
}
vOnePage.add(allList.get(i));
}
if (tmpCount<=counts) {
vAllPage.add(vOnePage);
}
this.maxPage = vAllPage.size();
if (this.nowPage>this.maxPage) {
this.nowPage = this.maxPage;
}
this.resultList = (Vector) vAllPage.get(this.nowPage-1);
}
}
相关文章推荐
- 常见的分页实现方式(Java)
- java实现多线程的一种简单方式
- 一种c#深拷贝方式完胜java深拷贝(实现上的对比分析)
- 一种好的JAVA分页实现
- 关于分页的一种实现方式--(js实现)
- Java枚举储存的一种索引实现方式
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- 大数据分页功能 的一种实现方式
- 一种c#深拷贝方式完胜java深拷贝(实现上的对比)
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- APP中一种在Java层实现的简单守护进程方式
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- Java并发问题--乐观锁与悲观锁以及乐观锁的一种实现方式-CAS
- Java与groovy混编 —— 一种兼顾接口清晰和实现敏捷的开发方式
- APP中一种在Java层实现的简单守护进程方式
- 又一种JSP实现的Java通用简单分页算法
- 多线程中的全局信息统计的一种简单实现方式(java实现)
- SQL 在查询中插入行号--自定义分页的另外一种实现方式