【问题标题】:RichFaces: How to reset page in datascroller after changes of values in dataTableRichFaces:如何在 dataTable 中的值更改后重置 datascroller 中的页面
【发布时间】:2016-06-02 17:45:17
【问题描述】:

我的rich:dataTablerich:datascroller,它运行良好,除了当我在任何页码(比如说5)上并执行搜索操作(或呈现数据表的任何操作)时。分页仍会显示第 5 页,但我希望在操作发生时将其重置为 1. 页。

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

这是我的代码 sn-p:

<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 的页面属性的值为 1。但这并没有解决问题。

我想知道我哪里出错了。

【问题讨论】:

  • 我尝试了 developer.jboss.org/thread/10566?start=0&tstart=0 的解决方案,但没有任何效果
  • 1.这不是错误。 2. 您在 jboss 论坛上写道“没有任何效果”,但您在此处粘贴了“an answer”,这是那里的第三个答案。

标签: jsf pagination richfaces datascroller


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-21
    • 2021-11-13
    • 2011-07-11
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    相关资源
    最近更新 更多