Find DataScroller current page
I'm using a dataTable with a dataScroller. I've added the 'Page' atribute to my dataScroller and put getter and Setters in the bean.
How can I check the current page a user is on in the bean?
Do I have to manually maintain the backing bean value each time a user selects a new page, hits next, previous, etc?
<a4j:outputPanel id="renderArea">
<rich:dataTable id="testTable" rows="5" value=开发者_JAVA技巧"#{testBean.myList}" var="item">
....
</rich:dataTable>
</a4j:outputPanel>
<!-- Get called when clicking on button inside renderArea -->
<a4j:commandButton id="HIDDENRERENDER" reRender="renderArea,PTScroll" value="+test" style="display:none"/>
<a4j:outputPanel id="PTScroll">
<h:panelGrid>
<rich:datascroller for="testTable" maxPages="20" renderIfSinglePage="false" page="#{testBean.myPage}" />
</h:panelGrid>
</a4j:outputPanel>
public class testBean
{
private int myPage = 1;
public void initialise()
{
this.setMyPage(0);
}
public int getMyPage()
{
return myPage;
}
public void setMyPage(int page)
{
this.myPage = page;
}
}
Thanks
You don't need to manually set the testBean.myPage
. It will automatically set to a new page number when you are navigating back and forth using the <rich:datascroller>
To change the page value programatically, just assign set a new page number to the testBean.myPage
in some action method. Then reRender the <rich:datascroller>
What scope do you use to call the testBean?
Try this, the paging works only in the first time:
@Named
@Singleton
public class testBean {
....
精彩评论