【问题标题】:How to refresh a row in Primefaces?如何刷新 Primefaces 中的一行?
【发布时间】:2015-05-29 06:38:23
【问题描述】:

在 Primefaces <p:dataTable> 中,每一行都有一个包含命令按钮的列。 这个commandButton更新了当前行对应的bean的值。

如何刷新我刚刚点击的当前行,以便阅读器栏刷新?

<p:dataTable id="repositoryBean" 
    currentPageReportTemplate="Total : {totalRecords}"
    lazy="true"
    resizableColumns="false"
    rows="200" 
    rowsPerPageTemplate="10,15,20"
    sortBy="#{row.name}"
    sortOrder="ascending"
    style="margin:20px 0px;"
    value="#{repositoryBean.users}"
    var="row"
    styleClass="small-datatable"
    editable="true"
   >
    <p:ajax event="rowSelect" listener="#{repositoryBean.onDisplay}"
        onstart="PF('loading').show()"
    /> 

    <p:column headerText="#{label.cvs_repo_user_firstname}" sortBy="#{row.firstname}" sortOrder="ascending">
        <h:outputText value="#{row.firstname}" />
    </p:column>
    <p:column headerText="#{label.cvs_repo_user_is_reader}" sortBy="#{row.reader}" sortOrder="ascending">
        <h:outputText value="#{row.reader}" />
    </p:column>

    <p:column headerText="#{label.cvs_repo_user_action}" style="text-align:center" >
        <p:commandButton
            value="Reader"
            styleClass="btn-off"
            action="#{repositoryBean.onSetReader(row)}"
            />
    </p:column>
</p:dataTable>

【问题讨论】:

  • “如何刷新我刚刚点击的当前行,以便阅读器列刷新?”:是否要更新包含某列的整行,还是只是特定的单元格?
  • 如果可能,完整的行,如果是唯一的解决方案,则只是单元格。

标签: jsf primefaces datatable


【解决方案1】:

为此使用 Omnifaces 实用程序库。它有 'Ajax' functionality 来更新数据表的行,甚至还有一个特定的 PrimeFaces 示例。

它的工作原理是:

Ajax.updateRow(table, index);

其中 table 是对组件的引用(不是 id!,而是通过绑定), index 是行索引。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    • 2012-10-31
    • 2013-04-07
    • 2014-01-17
    • 2013-09-07
    • 2012-01-25
    • 2015-03-29
    相关资源
    最近更新 更多