Search code examples
jsfdatatablejboss6.x

How do update jsf datatable column only


I have a counter in a column of a datatable. Once the counter reaches a certain time, I need to change the background color of that column only. The data for the table is being pulled from a database. I'm using a4j:poll to reRender the column but the issue is that the entire table is rendered. Some code below:

    <a4j:region>
        <h:form>
            <a4j:poll id="poll" interval="1000" enabled="true" reRender="blink" limitToList="true" />
        </h:form>
    </a4j:region>

<h:form id="form1">         
    <a4j:outputPanel id="panel1" ajaxRendered="true">               
    <h:dataTable id="blinks" styleClass="tableClass" value="#{bean.list}" var="_item">
<h:column id="blink">
  <f:facet name="header">
    <h:outputText value="Header1" />
  </f:facet>
    <div id="div1" class="#{bean.check() ? 'red' :''}">
            <h:outputText value="Counter text (counts seconds)" />
</h:column>
</h:dataTable>
</a4j:outputPanel>
</h:form>

Solution

  • If you meet the following minimum req' JSF 2.0, EL 2.1 and Servlet 2.5

    You can try out the Ajax#updateColumn() by Omnifaces , there is an example on how to use it in the showcase

    Note that Ajax#updateRow() and Ajax#updateColumn() can only update cell content when it has been wrapped in some container component with a fixed ID.