RichFaces:如何更改dataTable中的值后如何重置datascroller中的页面 [英] RichFaces: How to reset page in datascroller after changes of values in dataTable

查看:90
本文介绍了RichFaces:如何更改dataTable中的值后如何重置datascroller中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的rich:dataTablerich:datascroller,它工作正常,除了当我在任何页码上(比如说5)并执行搜索操作(或任何呈现dataTable的操作)时.分页仍将显示第5页,但我希望在操作发生时将其重设为1页.

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.

在此图像中,当我要转到第5页并再次点击搜索"或进行清除并再次搜索,分页仍设置为第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.

这是我的代码段:

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

我检查了其他解决方案.我尝试为datascroller实现page属性,但似乎无法正常工作.我在后备bean中创建了属性firstpage,当发生搜索时将其设置为"1",因此datascroller的page属性的值将为1.但这无法解决问题.

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.

推荐答案

我能够自己解决此问题.这是我所做的:

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>

首先要注意的是datascroller中的binding="#{prodClassificationBean.scroller}".

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

现在在辅助bean中:

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 

这篇关于RichFaces:如何更改dataTable中的值后如何重置datascroller中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆