Monday, December 12, 2011

ADF Tree - How to Add Checkbox

This is common request - to add checkbox next to ADF tree nodes. Obviously we should use ADF selectBooleanCheckbox component - however selectBooleanCheckbox is not propagated across ADF tree levels by default (applies to all ADF 11g versions). This post provides sample application for selectBooleanCheckbox rendering on different ADF tree node levels.

Download sample - TreeCheckBoxApp.zip (tested with ADF 11g R1 PS3/PS4).

Implemented tree renders two levels (Regions -> Countries):


Both level nodes are rendered with checkboxes. Checkbox is rendered based on transient EO attribute, Boolean type for Regions:


Same type attribute for Countries:


ADF tree binding contains both - Regions node name and checkbox definitions:


Similar binding for Countries:


ADF UI implements tree table (with selectBooleanCheckbox), first tree level is rendered from nodeStamp. As you can see both levels are getting values from node variable:


Let's run such tree - disabled checkboxes are rendered for empty level nodes - this is wrong:


How we can fix this? Add rendered expression for both selectBooleanCheckbox components. First level checkbox should be rendered only when RegionName is not Null:


Second level accordingly, when CountryName is not Null:


Now checkboxes are rendered correctly with ADF tree:


9 comments:

varun said...

Hi,

Great Post,

Could you also explain how to use multiple selection checkbox with tree instead of treetable. I need to select node-childs with checkbox.

Andrejus Baranovskis said...

I will need to look into this.

Regards,
Andrejus

Batimba said...

I have opened your project, changed my connection to my database. Build application went ok , but couldn't deployed the application. Got the <Stack trace for message 149004
weblogic.management.DeploymentException: Unmarshaller failed
error.

Regards
Marko

Andrejus Baranovskis said...

What version of JDev/ADF you are using?

Andrejus

Batimba said...

Studio Edition Version 11.1.1.5.0

Marko

Andrejus Baranovskis said...

It seems to work for me on the same version. I guess something with your environment.

Andrejus

Kyle Thomas said...

Marko,

Open your weblogic-application.xml in your META-INF folder and remove the reference to (top most):


adf.oracle.domain


The new version already adds one

Bala Mahesh said...

Hi,
I have similar requirement to use checkbox along with af:tree component. I have only one VO with master and child relationship defined using a ViewLink. No seperate Vos such as Region and Countries. Now if select a check box, my ValueChangeListener returns the first row always and not the current row. I have used the same code used in your example.

ADF OAF Tech said...

Hi Andrejus,

I am on 11.1.2.0.0 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.
Could you please help on the fix ?
Thanks,
Jit