Thursday, June 13, 2013

Clearing ADF Faces Table row section when change persistence is ON

Clearing af:table row section when change persistence is ON involves two steps:

1. Clearing the selected rows using table API
2. Call the change manager API to replace the current change persistence with an empty set

 Here is the code snippet for the above tasks:

public void clearRowSelection(RichTable table) {
    //Clearing the selected rows using table API 
    table.getSelectedRowKeys().clear();

    //Call change manager API to replace the
    //current change persistence with an empty set 
    RowKeySetAttributeChange rks =    new RowKeySetAttributeChange
        (table.getClientId(), 
            "selectedRowKeys", new RowKeySetImpl());
    RequestContext.getCurrentInstance().getChangeManager().
        addComponentChange(FacesContext.getCurrentInstance(),table, rks);
}