RichFaces: How to reset page in datascroller after changes of values in dataTable

我的未来我决定 提交于 2019-12-25 06:47:14

问题


I have rich:datascroller for my rich:dataTable which is working well except that when I am on any page number (let say 5) and do a search operation (or any operation which renders the dataTable). Pagination will still show page 5, but I want it to be reset to 1. page when the operation happens.

In this image, when I am going to Page 5 and hit Search again or do a clear and search again, the pagination is still set to Page 5, not back to Page 1.

Here's my code snippet:

<rich:datascroller id="prodDataScroller" for="prodClassificationOutputTable"
                   rows="100"   maxPages="10" fastStep="3" renderIfSinglePage="false"
                   immediate="false" page="#{prodClassificationBean.firstPage}">
</rich:datascroller>

<rich:dataTable id="prodClassificationOutputTable" border="0"
                width="100%" columnClasses="col" headerClass="column-header"
                style="overflow:auto;" rowClasses="odd,even" align="center"
                value="#{prodClassificationBean.outputClassificationWrappers}"
                var="prodClassificationRow" rows="100" rowKeyVar="row" immediate="true">
<!-- ... -->
<rich:dataTable>

I checked other solutions. I tried to implement page attribute for datascroller but it doesn't seem to be working. I created an attribute firstpage in backing bean being set to "1" when search happens so that page attribute of datascroller will have value as 1. But it's not resolving the issue.

I would like to know where I am going wrong.


回答1:


I was able to resolve the issue by myself. Here is what I did:

<rich:datascroller id="prodDataScroller" for="prodClassificationOutputTable"
                   rows="100" maxPages="10" fastStep="3" renderIfSinglePage="false"
                   binding="#{prodClassificationBean.scroller}">     
</rich:datascroller>
<rich:dataTable id="prodClassificationOutputTable" border="0" width="100%" 
                columnClasses="col" headerClass="column-header" 
                style="overflow:auto;" rowClasses="odd,even" align="center"
                value="#{prodClassificationBean.outputClassificationWrappers}"
                var="prodClassificationRow" rows="100" rowKeyVar="row" immediate="true">

    <rich:column align="center" width="20%">
        <f:facet name="header">
            <h:outputText value="ID" />
        </f:facet>
        <h:outputText style="font-weight:bold" value="#{prodClassificationRow.outputId}"/>
    </rich:column>

</rich:dataTable>

Among all, important to note is binding="#{prodClassificationBean.scroller}" in datascroller.

Now in the backing bean:

public class ProdClassificationBean {
    private transient HtmlDatascroller scroller; 
    //getter and setter for scroller

    // inside the action operation()
    if (scroller != null) {
        scroller.setPage("1");
    }
} // end of class 


来源:https://stackoverflow.com/questions/37598795/richfaces-how-to-reset-page-in-datascroller-after-changes-of-values-in-datatabl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!