'Usage of PrimeFaces.current().ajax().update for dataTable

Using PrimeFaces 6.2, I am currently trying to use ajax to update specific rows of a p:dataTable, but am having trouble. The statements which update the dataTable are in an event handler for cellEdit in a bean, as I'd like the table to be updated only after the edits performed by the cellEdit handler are performed.

Here is the section I am expecting to update the front end:

public void onCellEdit(CellEditEvent edit) {
    /// Do some modifications to a particular element in the backing data structure...
    ...

    DataTable dataTable = (DataTable) 
    FacesContext.getCurrentInstance().getViewRoot().findComponent("addForm:myDT");

    for(UIColumn col : dataTable.getColumns()) {
        PrimeFaces.current().ajax().update(col.getClientId());
        RequestContext.getCurrentInstance().update(col.getClientId());
        for(UIComponent child : col.getChildren()) {
            PrimeFaces.current().ajax().update(child.getClientId());
            RequestContext.getCurrentInstance().update(child.getClientId());
        }
    }
}

Note that I am just trying to be exhaustive here, I am aware RequestContext.update is deprecated, though I am unsure whether the children (i.e. outputText and inputText) is what should be targeted for update, or the parent column. Naively I assume updating the parent column will update the children, but this is just an assumption.

I am certain the backing data structure, a list of objects, is definitely being modified. I can observe the elements of the list do not match what is in the front end with breakpoint debugging.

Though I have not seen it in the documentation, .getClientId() is returning the id of the cell with the row number of the row which was modified in the CellEditEvent.

Any advice on why PrimeFaces.current().ajax().update or RequestContext.getCurrentInstance().update are not updating the front end in this instance would be much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source