Skip to main content

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);
}

Comments

Billy Bob Bain said…
This was very helpful!
Keith Reardon said…
2 questions for you, 1) does this same code apply for af:treeTable, I hope so as we have this problem with af:treeTable, and 2) is there something similar to clear the disclosed row keys in af:treeTable as they also appear to be persisted and that interferes with logic to programmatically set disclosed rows.
Ankur Pradhan said…
Hi,

I am working af:tree, I need to achieve same functionality for RichTree.

When I tried same approach, I am getting below exception

Caused by: java.lang.IllegalArgumentException: No clientId specified

Code Tried:

RichTree orderTree = this.getOrderTree();
orderTree.getSelectedRowKeys().clear();
RowKeySetAttributeChange rks = new RowKeySetAttributeChange(orderTree.getClientRowKey(),
"selectedRowKeys", new RowKeySetImpl());
RequestContext.getCurrentInstance().getChangeManager().
addComponentChange(FacesContext.getCurrentInstance(),orderTree, rks);
}

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…