Ofbiz 分页代码
来源:互联网 发布:网上卖数据 编辑:程序博客网 时间:2024/06/10 00:28
Delegator delegator = (Delegator) request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher) request
.getAttribute("dispatcher");
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue) session
.getAttribute("userLogin");
// 分页相关
String pageNumber = request.getParameter("pageNumber");
String pageSize = request.getParameter("pageSize");
// 当前页
int intPage = Integer.parseInt((pageNumber == null || pageNumber
.equals("0")) ? "1" : pageNumber);
// 每页显示条数
int number = Integer
.parseInt((pageSize == null || pageSize.equals("0")) ? defaultPageSize
: pageSize);
// 每页的开始记录 第一页为1 第二页为number +1
int lowIndex = (intPage - 1) * number + 1;
int highIndex = intPage * number;
EntityListIterator eli = null;
EntityFindOptions findOptions = new EntityFindOptions(true,
EntityFindOptions.TYPE_SCROLL_SENSITIVE,
EntityFindOptions.CONCUR_READ_ONLY, true);
// 根据用户loginId判断用户是否拥有系统管理员角色,如果有就任务是系统管理员,查询所有角色。
List<EntityCondition> connList = FastList.newInstance();
try {
TransactionUtil.begin();
eli = delegator.find("SecurityGroup",
EntityCondition.makeCondition(connList), null, null, null,
findOptions);
List<GenericValue> roleList = eli.getPartialList(lowIndex, number);
int totalPage = (eli.getResultsSizeAfterPartialList() + number - 1)
/ number;
request.setAttribute("pageSize", number);
request.setAttribute("totalPage", totalPage);
request.setAttribute("currentPage", intPage);
request.setAttribute("roleList", roleList);
TransactionUtil.commit();
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
try {
TransactionUtil.rollback();
} catch (GenericTransactionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} finally {
try {
if (eli != null) {
eli.close();
}
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
LocalDispatcher dispatcher = (LocalDispatcher) request
.getAttribute("dispatcher");
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue) session
.getAttribute("userLogin");
// 分页相关
String pageNumber = request.getParameter("pageNumber");
String pageSize = request.getParameter("pageSize");
// 当前页
int intPage = Integer.parseInt((pageNumber == null || pageNumber
.equals("0")) ? "1" : pageNumber);
// 每页显示条数
int number = Integer
.parseInt((pageSize == null || pageSize.equals("0")) ? defaultPageSize
: pageSize);
// 每页的开始记录 第一页为1 第二页为number +1
int lowIndex = (intPage - 1) * number + 1;
int highIndex = intPage * number;
EntityListIterator eli = null;
EntityFindOptions findOptions = new EntityFindOptions(true,
EntityFindOptions.TYPE_SCROLL_SENSITIVE,
EntityFindOptions.CONCUR_READ_ONLY, true);
// 根据用户loginId判断用户是否拥有系统管理员角色,如果有就任务是系统管理员,查询所有角色。
List<EntityCondition> connList = FastList.newInstance();
try {
TransactionUtil.begin();
eli = delegator.find("SecurityGroup",
EntityCondition.makeCondition(connList), null, null, null,
findOptions);
List<GenericValue> roleList = eli.getPartialList(lowIndex, number);
int totalPage = (eli.getResultsSizeAfterPartialList() + number - 1)
/ number;
request.setAttribute("pageSize", number);
request.setAttribute("totalPage", totalPage);
request.setAttribute("currentPage", intPage);
request.setAttribute("roleList", roleList);
TransactionUtil.commit();
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
try {
TransactionUtil.rollback();
} catch (GenericTransactionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} finally {
try {
if (eli != null) {
eli.close();
}
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
1 1
- OFBIZ 分页代码
- OFBIZ 分页代码
- OFBIZ 分页代码
- Ofbiz 分页代码
- ofbiz 分页代码
- OFBIZ 分页代码
- OFBiz框架实现分页效果
- ofbiz缺省国家代码
- ofbiz框架入门例子详解-------分页篇
- ofbiz
- OFBiz
- OFBIZ
- OFBiz
- ofbiz
- ofbiz
- OFBIZ
- OFBIZ
- OFBIZ
- 多种常用工具类
- Android开发中使用Fragment造成的图像残留问题
- Spring注解
- 黑马程序员——util工具类
- 浅谈C++多态性
- Ofbiz 分页代码
- 最小生成树Prim and Kruskal
- 字节转换之大小端
- python字符串字串查找 find和index方法
- 内存越界和局部变量、数组初始化
- scrapy爬虫起步(4)-- 来个scrapy的简介吧
- 淘宝开源项目TbSchedule的部署和使用
- Oracle SQL性能优化常用方法
- Linux网络编程——tcp并发服务器(poll实现)