Chris Barham 先生在 http://code.google.com/p/pagingappfuse/ 给出了 AppFuse 中 DisplayTag 组件外部排序和分页的过程,他使用了spring mvc ,我需要转换为 struts2,但我是 AppFuse 新手,许多地方不明白,请教各位。
Chris Barham需要转换的代码如下:
[code="java"] export="true" pagesize="25">
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"] pagesize="5" style="width:1000px;white-space:nowrap;">
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,
文档说,外部分页可使用如下形式:
不知道它和实现 PaginateList 接口的方式有何区别?
4、分页后出现一个奇怪问题:
customer表中有4条记录,id=-3,-2,-1,1
采用外部分页后,读取的记录有
id=-3,-3,-2,-2,-1,1
6条记录,前2条重复了1次,后2条不重复。而未采用外部分页时,正常显示4条记录。是何原因?
如能再次给我解答,非常感谢!
我对Display Tag了解也不多.仅凭个人理解,你最好查看对应API或者文档;
[quote]1、采用外部分页后,打开web页面很慢,比displaytag自己分页要慢一个数量级,应该是这样吗? [/quote]
外部分页,应该是全部数据的排序分页; 可能要慢.
[quote]2、displaytag自己分页时,点一行直接进入该行详细页面,但外部分页后,就不行了,不知何故? [/quote]
外部分页的索引ID,应该已经不能取了.要添加页码等处理;
http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html
好像有说明.你再看看.
[quote]3、看了http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html,
文档说,外部分页可使用如下形式:
不知道它和实现 PaginateList 接口的方式有何区别? [/quote]
同1.整个分页好像不是真对当前结果;而是真对所有结果.
[quote]4、分页后出现一个奇怪问题:
customer表中有4条记录,id=-3,-2,-1,1
采用外部分页后,读取的记录有
id=-3,-3,-2,-2,-1,1
6条记录,前2条重复了1次,后2条不重复。而未采用外部分页时,正常显示4条记录。是何原因? [/quote]
应该是记录结果分页导致的; 不过具体程序我没看;
不敢随便下结论;
你要多看看APi和文档.
你的name属性不对,设置为 MycustomerListId
[code="java"]<display:table name="MycustomerListId" class="table" requestURI="" id="MycustomerListId"[/code]
这样就可以;
DisplayTag Reference:
[url]http://displaytag.sourceforge.net/11/displaytag/tagreference.html#table[/url]