ADF: Handling deletion in TreeTables

For the current project that I am working for, we had the requirement to display information in a table that should consist of Master and Detail rows. I knew that there is a component in ADF to solve this requirement quite easily: af:TreeTable.

af:treeTable

So I added my master as a TreeTable component and added the detail as a new level. Under display attributes you can select the attributes that shall be displayed.

Unbenannt

After adding the af:treeTable component you have to adjust the components in your page –

Unbenannt

for example will the added attributes be displayed in one af:outputText component in one node. To change that add new columns to the tree table by performing a rightclick on it -> insert inside Tree Table -> column. You can choose the values by using writing for example:

value=”#{node.Name}”

Hint: In Jdeveloper version 12.1.3 I faced the issue that there was only an autosuggest for the Master attributes. Just type your detail attributes likewise, seems like this is a bug.

Deleting selected row

When it came to deleting rows I had the same problem as probably  many more developers before me: I thought that I can just use the standard delete operation from the bindings. Well that is just working for the master. So I did some research and found following blog entry:
http://www.jobinesh.com/2010/05/crud-operations-on-tree-table.html

The author discribes how to implement methods in the Bean to extract the RowIterator and the key of the af:TreeTable. With that you can implement a method in the model to delete the any selected row and add it as a client implementation.

After that I asked myself, if that was all or if I would have to implement some more. You have to modify your association to be able to delete Master records and cascade the deletion to the details. For that, open the association and click on relationship. Under behavior you find the option composite association & implement cascade delete. When you select this option, the deletion of a master row will result in deleting all child records.

Unbenannt

 

 

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s