Thursday, December 15, 2011

ADF Tree - How to Autoselect/Deselect Checkbox

If you want to add selection checkbox to ADF tree, read this post - ADF Tree - How to Add Checkbox. Today I will describe how to implement auto-selection for the same checkbox. Checkbox selection will be calculated using Groovy, based on additional helper attribute.

Download updated sample application - TreeCheckboxApp_v2.zip. This sample is extended with additional helper attribute on EO level, for Regions and Countries EOs. This is transient String type attribute - RegionConfirmedStatus for Regions EO:


RegionConfirmed boolean attribute value is calculated trough Groovy, based on RegionConfirmedStatus character value - Y = true, else = false. This is required, otherwise boolean value is not changed directly. It works well, when value is calculated from Groovy:


Same for Countries EO - CountryConfirmed attribute:


On UI, ADF UI component - selectBooleanCheckbox, should be configured with value change listener and enabled with auto submit - this allows to catch checkbox change event:


Value change listener is not changing boolean value directly, but is changing only helper attribute value (Y/N). When change is performed, Groovy is fired on EO level and recalculates main boolean attribute value used for checkbox. If we would change boolean value directly, this value is not preserved and is reset back to original value during next refresh. Helper attribute value is changed for Regions level as well as for Countries level (iterating over detail collection):


Implemented functionality - user selects top level node - dependent child nodes are auto-selected (and opposite on deselect):


2 comments:

Anonymous said...

i need a tutor for this step by step T_T

Andrejus Baranovskis said...

Yes, we are doing trainings as well. Please log training request on http://redsamoracle.wikispaces.com or drop me email.

Andrejus