在Web应用开发中,不管是有没有数据库,经常要用到分页处理问题。EasyJWeb中通过引入IPageList接口来轻松解决我们的遇到的各种分页问题,包括对数据库记录分页、文件目录分页、数组或者Java对象分页等。 EasyJWeb作为一个Web框架,其MVC核心中本身没有包含分页的内容,我们这里所说的分页设计是指在EasyJWeb Tools业务引擎中关于分页需求应用的设计。 1、应用示例代码 首先们看看该分页设计的有关应用示例代码,该示例的完整代码可在http://www.easyjf.com/download.htm 中下载! 示例代码A: com.easyjweb.action.userManageAction.java 这是EasyJWeb文档中示例3(添删改查)中有关记录分页显示的部分代码: public class userManageAction extends AbstractCrudAction { public IPageList doQuery(WebForm form, int currentPage, int pageSize) { .... DbPageList pList=new DbPageList(User.class,scope,paras);//通过调用DbPageList对象,返回分页结果IPageList pList.doList(currentPage,pageSize); return pList; } ... 从代码中我们可以看出,这是一个对数库记录集对象的分页处理例子。直接通实现了IPageList接口的DbPageList类实现数据库的分页。 示例代码B: net.meybo.mail.action.EmailAction.java 这是MeyboMail Web邮件客户端开源简化版中,中对邮件主题进行分页显示的代码。 public class EmailAction implements IWebAction { ... private Page doList(WebForm form, Module module,ActiveUser user) { ... List list=null; ... list=EmailManage.getMailList(user.getUserName(),user.getServerDomain(),boxName); IPageList pList=new PageList(new ListQuery(list)); if(pList!=null){ pList.doList(pageSize,currentPage,"",""); form.addResult("list",pList.getResult()); form.addResult("pages",new Integer(pList.getPages())); form.addResult("rows",new Integer(pList.getRowCount())); form.addResult("page",new Integer(pList.getCurrentPage())); form.addResult("gotoPageHTML",CommUtil.showPageHtml(pList.getCurrentPage(),pList.getPages()));
复制本页网址和标题,发送给你QQ/Msn的好友一起分享
上一篇:什么是 JSP 技术?
下一篇:关于JSP Commons FileUpload 组件上传文件的一些总结