Referencing dataTable footer

萝らか妹 提交于 2019-12-02 13:26:23

问题


I am trying to use Ajax updates triggered from a component within a p:dataTable to update the footer of the table. But no matter how I write my ID references in the p:ajax tag I don't seem to be able to get them right.

This is an example:

<h:form id="formId">

  <p:dataTable id="tableId" var="row" value="#{testBean.dataRows}" rowIndexVar="rowIx">
    <p:column>
      <h:outputText value="#{row}"/>

      <p:inputText id="innerInputId" value="#{testBean.str}">
        <p:ajax event="keyup" update="tableId:footerId"/>
        <p:ajax event="keyup" update=":formId:tableId:footerId"/>
        <p:ajax event="keyup" update="@form:tableId:footerId"/>
      </p:inputText>

      <f:facet name="footer">
        <h:outputText id="footerId" value="#{testBean.str}"/>
      </f:facet>
    </p:column>
  </p:dataTable>

  <p:inputText id="outerInputId" value="#{testBean.str}">
    <p:ajax event="keyup" update="tableId:footerId"/>
  </p:inputText>

</h:form>

In the generated HTML I can see that the outputText in the footer gets the ID formId:tableId:footerId.

The reference from outerInputId works fine.

All of the references from innerInputId I expect to work, but they don't. In the generated HTML I can see that they are translated into the form formId:tableId:0:footerId. This would make sense if the footer was located inside the naming container of the current row, but it isn't as I can see from its ID.

I smell a bug here. Am I right? How can I work around it?

Or is this expected behaviour, and in that case why?

I want to do this to display the sum of all the cells in the column in the footer.

Relevant software: PrimeFaces 5.1, Mojarra 2.2.7, GlassFish 4.1

来源:https://stackoverflow.com/questions/26524531/referencing-datatable-footer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!