4 Replies Latest reply on Apr 29, 2010 9:33 AM by tomtom333

    Why does a subTable break a4j:commandLink’s reRender?

    tomtom333

      Below is a minimal rich:dataTable example with an a4j:commandLink inside. When clicked, it sends an AJAX request to my bean and reRenders the dataTable.

       

      <rich:dataTable id="dataTable" value="#{carManager.all}" var="item">
          <rich:column>
              <f:facet name="header">name</f:facet>
              <h:outputText value="#{item.name}" />
          </rich:column>
          <rich:column>
              <f:facet name="header">action</f:facet>
              <a4j:commandLink reRender="dataTable" value="Delete" action="#{carForm.delete}">
                      <f:setPropertyActionListener value="#{item.id}" target="#{carForm.id}" />
                      <f:param name="from" value="list" />
              </a4j:commandLink>
          </rich:column>
      </rich:dataTable>
      

       

      The exmaple obove works fine so far. But when I add a rich:subTable (grouping the cars by garage for example) to the table, reRendering fails...

       

      <rich:dataTable id="dataTable" value="#{garageManager.all}" var="garage">
          <f:facet name="header">
              <rich:columnGroup>
                  <rich:column>name</rich:column>
                  <rich:column>action</rich:column>
              </rich:columnGroup>
          </f:facet>
      
          <rich:column colspan="2">
              <h:outputText value="#{garage.name}" />
          </rich:column>
      
          <rich:subTable value="#{garage.cars}" var="car">
              <rich:column><h:ouputText value="#{car.name}" /></rich:column>
              <rich:column>
                  <a4j:commandLink reRender="dataTable" value="Delete" action="#{carForm.delete}">
                          <f:setPropertyActionListener value="#{item.id}" target="#{carForm.id}" />
                          <f:param name="from" value="list" />
                  </a4j:commandLink>
              </rich:column>
          </rich:column>
      </rich:dataTable>
      

       

      Now the rich:dataTable is not rerendered after a click but the item is removed from database since the item does not show up after a manual page refresh.

       

      What is wrong with the second example? Are there better alternatives to updating the whole table?

       

      Tanks Tom