简体   繁体   English

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

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

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). 我的rich:dataTablerich:datascroller ,它工作正常,除了当我在任何页码上(让我说5)并执行搜索操作(或任何呈现dataTable的操作)时。 Pagination will still show page 5, but I want it to be reset to 1. page when the operation happens. 分页仍将显示第5页,但我希望在操作发生时将其重设为1.页。

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. 在此图像中 ,当我转到第5页并再次单击“搜索”或进行清除并再次搜索时,分页仍设置为第5页,而不是回到第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. 我尝试为datascroller实现page属性,但似乎无法正常工作。 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. 我在后备bean中创建了属性firstpage ,该属性在发生搜索时被设置为“ 1”,因此datascroller的page属性的值将为1。但这无法解决问题。

I would like to know where I am going wrong. 我想知道我要去哪里错了。

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. 其中,值得注意的是binding="#{prodClassificationBean.scroller}"

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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM