Sunday, November 18, 2012

Check Box Support in ADF Tree Table Different Levels

Year ago I had a blog post about workaround to render check box in ADF tree table - ADF Tree - How to Autoselect/Deselect Checkbox. This was implemented with previous JDeveloper 11g R1 PS4 version. However, there is no need to have described workaround anymore, check box and ADF tree table combination works much better in JDeveloper 11g R2 version - Based on blog reader request, I will post today updated sample application -

Both entities - Regions and Countries have special attribute of Boolean type, this attribute will be rendered as check box in ADF UI tree table component. There is no need to have helper attribute as we had before. Regions entity:

Countries entity:

Once Regions check box is checked - all Countries are checked (and vice versa). We can control this from managed bean - listening for value change event in Regions and resetting Countries:

On ADF UI side, in order to be able to render proper tree table structure with check boxes - don't forget to set rendered expression, we want to render check box only for such rows, where check box value is not Null:

Take a look how it is displayed on UI. China is selected, from Asia group:

Select Asia check box - all countries from Asia will get selected automatically (thanks to managed bean method we have implemented above):

Uncheck Asia check box - all dependent check boxes are unchecked:

While Region check box is checked, you can uncheck/check Countries check box as well. This is one of the most typical use cases for check box support in ADF tree table.


Renan Monteiro's Sharepoint said...

Hello Andrejus!

There is still some strange behaviour happening on that demo...

If you select a row and that correspondent checkbox after it works!
But if you directly select the checkbox you need a double click to have it checked... It happens both on parent nodes and on child nodes (tested on Firefox and Chrome).

Does it happen to you too?

Andrej Baranovskij said...


Nope - this wasnt happening, when I was testing. I using latest JDev 11g.


Anonymous said...

I have a treetable with checkboxes where the parent and child is one viewobject. Like the employee id and manager id in the employee viewobject. How to uncheck/check all the child based on the parent uncheck/check?

Anonymous said...

I need to get the data of the tree table rows for which the check boxes are selected in the backing bean? Normal iteration to check 'if the check box is true' is not working.

Unknown said...

Hello Andrejus!
Thanks for a nice post atleast it provided a light in the darkness.
In my project we have to build a tree hiearchy
Root Level-project id
level1- Activity level
level 2- task level
level3 - sub task level
and further if any sub-sub task is there.
It can have n level of hierarchy.I have created 3 sql query based vo's and they are linked internally through join statement. and then i have created 2 view links
i have created 3 transient attribute in all 3 vo's.
But,as per your solutions you have child component in different column. But my results set brings the hierarchy in a single column and I am able to put only 1 single checkbox and bind it to only Parent level transient attribute and not able to use other transient attribute
Please let me know how to implement it for 'n' level hierarchy and checkbox functionality in my case

ADF OAF Tech said...

Hi Andrejus,

I am on version. I tried your application. It works fine. However when i click check box first time it is not checking. It works when we click Check Box second time.

Same thing mentioned by Renan Monteiro's Sharepoint above.

Could you please help on the fix ?

Andrej Baranovskij said...

This will be probably a bug in 11.1.2 version.


Anonymous said...

I need to uncheck the same checkbox when it is checked after some calculation.
Is there any way to do that?

Lakshmi said...

Hi Andrejus,

I tried the similar approach in JDev 11g PS6 ADF. I am having a tree structure that display 4 levels of information. The checkbox functionality working only for first time. Later debugging the code, I realized that, iterator.hasNext() is returning false from second time. Let me know how to handle this issue. Thanks.

Fabio said...

Hi Andrejus,

Everything works fine, but this solution is only for two levels treetable.
I've a treetable with unbounded levels, so how can I manage it?

I would like to know if you have a more scalable solution for the checkbox support in ADF treetable.

Thanks a lot.

Andrej Baranovskij said...

I guess then you should do the same through hierarchycal View Link. I dont have sample for this.


Fabio said...

Yes, I've done.

But I don't know how manage it in the bean class