views:

351

answers:

1

Here 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 but the item gets deleted since the item does not show up after a manual page refresh.

Why does subTable break support for reRender-ing here?

Tanks Tom

A: 

It turned out that Hibernate did not update the list of the related models.

After removing the Car using AppFuse's carManager, the deleted car still showed in the getCars()-list of the associated Garage [when receiving the Garages using garageManager.getAll()].

So the problem was not related to richfaces itself!

Currently I'm using a workaround (deleting the items manually when receiving the data from the related model oO) but maybe I'll open a new question to solve this problem.

Tom