Site icon Experiences Unlimited

Understanding RowKey values in ADF TreeTable

For those working on ADF and using TreeTable or other Tabular components would have always wondered about this RowKey and lot of times many of the would have encountered the deadly NoSuchRowAvailable Exception.

If you want to just know about the RowKeyIndex, then you can download the sample application from here and directly go to the Understanding RowKeyIndex section.

Creating the Sample Application

Basic skeleton application

The complete code can be downloaded from here.

Printing the rowKey on the page

In thie section we will look at capturing the rowKey of the selected row and print in it on the web page. The source code can be downloaded from here.

After deploying the application, click on the treeTable row and see how the value in the outputText varies, also try with multiple selections.

Understanding the RowKeyIndex

Now that you have got an idea about the values for the selected row’s rowKey or for that matter any rowKey in a TreeTable, let me throw some light on the format and the rowKey values you see.

The rowKey is a list of list of integers- the outer most list is applicable when there are multiple rows being selected, in case of single row being selected the outer most list would always have only one value. The inner most list is something which is worth spending more time on. The inner most list is a list of integers using which one can traverse from the root node to the node which is selected.

Let me explain by taking more examples from the treeTable created above:
(Identifying the rows can be done as: the first part refers to “First Name” column and the second part refers to the “Last Name” column)
Selecting on “First Manager” would print: [[0]]
Selecting on “First Sub_1” would print: [[0,0]]
Selecting on “First Sub_2” would print: [[0,1]]
Selecting on “First Sub_3” would print: [[0,2]]
Selecting on “Sub_3 Sub_1” would print: [[0,2,0]]

Selecting on “Third Manager” would print: [[2]]
Selecting on “Third Sub_1” would print: [[2,0]]
Selecting on “Third Sub_2” would print: [[2,1]]
Selecting on “Third Sub_3” would print: [[2,2]]

Looking at the values above we see that

So the effective rowKey of a selected row would be decided by traversing from the root till the selected node and noting the index of each node appearing in the traversal.

Now lets see how this value would vary when we do multiple selections. I will add the screenshot with the RowKeyIndex value printed in the outputText at the bottom of the treeTable.

Its important to know about RowKeyIndex because all the data idenfitication in the TreeTable/Tree/Table is done based on this RowKeyIndex value. In the future posts I will show you why you come across exceptions like “NoSuchRowAvailable” exception while dealing with refreshing the data in the TreeTable

If you want to play around with the code, please download the JDeveloper project and then run the application.

Exit mobile version