Chris Barham 先生在 http://code.google.com/p/pagingappfuse/ 给出了 AppFuse 中 DisplayTag 组件外部排序和分页的过程,他使用了spring mvc ,我需要转换为 struts2,但我是 AppFuse 新手,许多地方不明白,请教各位。
Chris Barham需要转换的代码如下:
[code="java"]
public class AuthorityController implements Controller {
...
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
ExtendedPaginatedList paginatedList = paginateListFactory
.getPaginatedListFromRequest(request);
manager.getAllRecordsPage(Authority.class, paginatedList);
return [b]new ModelAndView().addObject("authorityList", paginatedList); [/b]
}
...
}
[/code]
我要转换成:
[code="java"]
public class CustomerAction extends BaseAction implements Preparable {
...
public String list() {
ExtendedPaginatedList paginatedList = paginateListFactory.getPaginatedListFromRequest(getRequest());
pagingManager.getAllRecordsPage(Customer.class, paginatedList);
[b]getRequest().setAttribute("MycustomerListId", paginatedList); [/b] //这是最主要的改变
return SUCCESS;
}
...
}[/code]
在 eclipse 中调试时发现 paginatedList 已经有正确的数据集合了,但是找不到 MycustomerListId ,显示的页面是空表,没有数据。请教,如何才能设置正确的返回结果集?
[b]问题补充:[/b]
谢谢bohemia,可以使用了,但是好象还有点问题。
1、采用外部分页后,打开web页面很慢,比displaytag自己分页要慢一个数量级,应该是这样吗?
2、displaytag自己分页时,点一行直接进入该行详细页面,但外部分页后,就不行了,不知何故?
3、看了http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html,
文档说,外部分页可使用如下形式:
4、分页后出现一个奇怪问题:
customer表中有4条记录,id=-3,-2,-1,1
采用外部分页后,读取的记录有
id=-3,-3,-2,-2,-1,1
6条记录,前2条重复了1次,后2条不重复。而未采用外部分页时,正常显示4条记录。是何原因?
如能再次给我解答,非常感谢!