Saturday, November 26, 2011

ADF: Panel Tabbed Inter-Region Communication through shared bean datacontrol

Tested with JDeveloper

Use Case

  • JSF Page with two tabs (Departments, Employees)
    image The DepartmentName is rendered as a command link. If the user clicks on a DepartmentName the view changes on to the Employees Tab and filters the data
  • In each tab there is an static adf region (bound to fragment based BTF)
In summary we need the following to do:
  • DepartmentName as command link
  • View switches to the Employees Tab
  • Tab text should change to “Employees (<DepartmentName>)
  • On the employees tab - of course – only the corresponding entries should be displayed
  • The employees tab contains a button to remove the “global” filter.

How to do it?

Create DataExchange Bean as follows
public class DeptEmpExchange {
    private Number deptId;
    private String deptName;
    public DeptEmpExchange() {
        System.out.println("DeptEmpExchange created " + this);
    public void setDeptId(Number deptId) {
        this.deptId = deptId;
    public Number getDeptId() {
        return deptId;
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    public String getDeptName() {
        return deptName;
     * Exposed as DC Operation.
     * Called from the dept btf
     * @param deptId
     * @param deptName
    public void onDepartmentChange(final Number deptId,
                                   final String deptName) {
        System.out.println("onDepartmentExchange called: " + deptId + "/" + deptName);
        View1Bean view1 = (View1Bean)JSFUtils.resolveExpression("#{View1Bean}");
        view1.setEmpTabText("Employees ("+deptName+")");
And expose as JavaBean DataControl.
Now, on depts page fragment: drop the exposed operation onto the command link and provide the parameters from the current row.
The refresh of the panel tabbed is done programmatically in the onDepartmentChange(..) method. In order to refresh the emp btf with the new dept id configure the following bindings / properties on the main page
- create an attribute binding on the deptId from the DeptEmpExchange Bean.
- bind the tf input parameter to the attribute binding
- do not forget to set refresh=ifNeeded => this causes the btf to refresh in case the input params will change.
Implementing the “remove global filter” functionality is pretty simple. Just drag the onDepartmentChange-Operation from the data control palette on to the toolbar and adjust the text.

I hope I have not forgotten any important steps.

Download JDev11112Workspace

Update on Dec 19th 2011: Added Sample Application