RichFaces:如何在dataTable中更改值后重置datascroller中的页面

时间:2016-06-02 17:45:18

标签: jsf pagination richfaces datascroller

rich:datascroller的{​​{1}}效果很好,除了当我在任何页码上(比方说5)并进行搜索操作(或任何呈现dataTable的操作)时。分页仍将显示第5页,但我希望在操作发生时将其重置为1.页面。

在这个image中,当我要再次点击搜索或再次进行搜索并再次搜索时,分页仍然设置为Page 5,而不是返回第1页。

这是我的代码段:

rich:dataTable

我检查了其他解决方案。我尝试为datascroller实现<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> 属性,但它似乎并没有起作用。我在支持bean中创建了一个属性page,设置为&#34; 1&#34;当搜索发生时,datascroller的页面属性值为1.但是它没有解决问题。

我想知道我哪里出错了。

1 个答案:

答案 0 :(得分:0)

我能够自己解决这个问题。这是我做的:

<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>

其中,值得注意的是datascroller中的binding="#{prodClassificationBean.scroller}"

现在在支持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