关于rich:datascroller当前页码的保存与恢复
[原创于:http://happydev.iteye.com]
在使用rich:datascroller配合rich:dataTable使用过程中,经常会有这样的使用场景:要保存当前页码,然后跳转到一个其它的页面,当返回时又要恢复保存的页码。
本文就如何实现这样的一个应用场景进行一下说明:
创建一个保存当前页面代码的组件
@Name("pageHolder")
@Scope(ScopeType.CONVERSATION)
public class PageHolder {
private int currPage;
@Begin
@Create
public void creat(){
System.out.print("test");
}
public void lsn(DataScrollerEvent event) {
// 当前点击的页数
String pageCount = event.getNewScrolVal().toString();
this.currPage=Integer.parseInt(pageCount);
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public int getCurrPage() {
return currPage;
}
}
页面代码:
<rich:datascroller pageIndexVar="currPage" scrollerListener="#{pageHolder.lsn}" page="#{pageHolder.currPage}" align="left" for="entGeneralAccountList" maxPages="20" rendered="#{entGeneralAccountList.rowCount > 20}"/>
<rich:spacer height="30" rendered="#{entGeneralAccountList.rowCount > 20}"/>
<rich:dataTable width="100%" id="entGeneralAccountList" rows="20" columnClasses="col" value="#{entGeneralAccountList}" var="entGeneralAccount">
测试了下这样会存在问题,直接点击上一页,下一页等时候,传入u的参数是first、 fastrewind、fastforward、last,Integer.parseInt(pageCount);就会出现问题了,所以其实不用这么麻烦,直接缓存currPage就好了,不用监听
写得不错,这几天正在想怎样这类问题,刚刚找到您的文章,受益啦。。谢谢
请教一下,DataScrollerEvent这个是什么??
本来就分得很开啊。
请教一个seam分层的问题,将action和ui分开能分吗?
恩,写的很好,谢谢了。如果可以加分的话一定给你很多很多的........分.