开发者

Keeping current JSF pagination state when going to another page and coming back to the page that contains the paginator

I'm using the Tomahawk t:dataScroller for pagination. It is working really well. There is only one issue that I'll try to explain:

Page A contains the t:dataTable, which is paginated with the t:dataScroller. There are links in the dataTable that can redirect me to another page, say page B. When I go back from B to A, the state of the pagination is restarted.

What I mean is that, if, in Page A, I'm at the 5th page, and then move to page B, when I go back to A, I'll be at the 1st page on A.开发者_如何转开发

Does anyone have gone through this? Does anybody have any idea?


You can take control of 'first' property of the datatable. What you need to this,

  1. Declare a public/protected variable in your session bean,

    @ManagedBean @SessionScoped public class DataTableController implements java.io.Serializable { protected int first; // getters and setters...

  2. Bind it with the 'first' property of datatable

    <p:dataTable id="results-table" var="result" ... first="#{dataTableController.first}"

  3. While navigating between the pages, store the 'first' record value using something like this,

    public void onPageChange(PageEvent event) { this.setFirst(((DataTable) event.getSource()).getFirst()); }

For more details, follow the link. http://forum.primefaces.org/viewtopic.php?f=3&t=25399#p80324

BTW Thanks for the comments

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜