Pages

Thursday, November 7, 2013

ADF TreeTable - Create new child under selected record

In this example i am adding Create operation to TreeTable (Similarly you can do for Tree also).

To create a ADF TreeTable please fallow this post, Hierarchy Viewer and Tree Table Sample

Modify existing EmployeeAM and added new view instance "CreateEmployeeVO".


Create AM class "EmployeeAMImpl" and added "createEmployee" method.



Create ADF form based on the newly created "CreateEmployeeVO".


Create page bindings to "add new row" and "createEmployee" method.


To create a child under selected node, we need to identify the selected node.

to get he selected node from TreeTable we need to use the iterative Key method.

    public Key getSelectedNodeRowKey() {
        if (treeTable != null && treeTable.getSelectedRowKeys() != null) {
            for (Object key : treeTable.getSelectedRowKeys()) {
                treeTable.setRowKey(key);
                return ((JUCtrlHierNodeBinding)treeTable.getRowData()).getRowKey();
            }
        }
        return null;
    }
   
    public RowIterator getSelectedNodeRowIterator() {
        if (treeTable != null && treeTable.getSelectedRowKeys() != null) {
            for (Object key : treeTable.getSelectedRowKeys()) {
                treeTable.setRowKey(key);
                return ((JUCtrlHierNodeBinding)treeTable.getRowData()).getRowIterator();
            }
        }
        return null;
    }


Sample UI screen shots.


You can download the sample code.

0 comments:

Post a Comment