0

我的分页~~~

 7 months ago
source link: https://www.jdon.com/14385.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

我的分页~~~

分为三个部分:持久层分页,界面显示(标签库),分页控制.
分页控制是界面显示,持久层分页的连接点.采用AbstractPagerHelper实现:
public abstract class AbstractPagerHelper {
public PageControl newPageControl(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
..................
return pageControl;
}
//每页显示的数据集合,可以在其中调用业务层或持久层方法
public abstract Collection getPagerData(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response,
long start,
long count)
throws Exception;
//总行数,可以在其中调用业务层或持久层方法
public abstract long getRowCount(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception;
}

持久层:
抽象Hibernate的Dialect,实现分页语法的简单封装.

在Action中:
PageControl pageControl = new AbstractPagerHelper() {
...//两个抽象类的实现(从业务层或持久层获取数据),newPageControl会调用这两个方法
}.newPageControl(mapping,form,request,response);
request.setAttribute("pageControl",pageControl);

jsp界面(标签库的样式是模仿bang的:),可以扩展更多的样式):
<smile:pager name="pageControl" page="/personBaseList.do?query=mmm">
<smile:first>First Page</smile:first> 
<smile:prev>Pre Page</smile:prev> 
<smile:index/> 
<smile:next>Next page</smile:next> 
<smile:last>Last Page</smile:last> 
</smile:pager>
<logic:iterate id="ps" name="pageControl" property="data" type="com.smiletilly.job.person.entity.PersonBaseInfo">
<tr>
<td><bean:write name="ps" property="id"/></td>
<td><bean:write name="ps" property="name"/></td>
</tr>
</logic:iterate>

欢迎讨论~~~
注:公司的分页我是直接利用我分页,而不是反向关系(因为公司对信息安全过分注重,故提到这一点).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK