`
happylo
  • 浏览: 46798 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

关于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">

 

分享到:
评论
6 楼 yuanliyin 2010-11-12  
测试了下这样会存在问题,直接点击上一页,下一页等时候,传入u的参数是first、
fastrewind、fastforward、last,Integer.parseInt(pageCount);就会出现问题了,所以其实不用这么麻烦,直接缓存currPage就好了,不用监听
5 楼 rainliu 2009-07-29  
写得不错,这几天正在想怎样这类问题,刚刚找到您的文章,受益啦。。谢谢
4 楼 caoxiaohui 2009-03-30  
请教一下,DataScrollerEvent这个是什么??
3 楼 happylo 2009-03-03  
joysoftfan 写道

请教一个seam分层的问题,将action和ui分开能分吗?

本来就分得很开啊。
2 楼 joysoftfan 2009-03-02  
请教一个seam分层的问题,将action和ui分开能分吗?
1 楼 sunjia2003112407 2009-02-19  
恩,写的很好,谢谢了。如果可以加分的话一定给你很多很多的........分.

相关推荐

Global site tag (gtag.js) - Google Analytics