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):


12 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

Batimba said...

Is it possible to have regionconfirmed and countryconfirmed as database columns(not transit)

Marko

Andrejus Baranovskis said...

Yes, then it should be even easier to implement.

Andrejus

Batimba said...

I have problem with auto refresh, when I trigger it manualy I see the columns are updated correctly, so bean works

Batimba said...

OK I solved autorefresh, now I would need to try one more level (for example department)
I have country-location-department tree
, tree works I only don't know how to autoselect all departments in specific location (autoselect from second level)


Tried like this, but I get null value along the way

DCIteratorBinding dcIb = ADFUtils.findIterator("CountryView1Iterator");
CountryViewRowImpl country = (CountryViewRowImpl)dcIb.getCurrentRow();
RowIterator ri = country.getLocationView();
LocationViewRowImpl location = (LocationViewRowImpl)ri.getCurrentRow();
RowIterator riloc = location.getDepartmentView();

Batimba

Renan Monteiro's Sharepoint said...

Hello Andrejus!

Unfortunately the sample is not working anymore on JDev 11gR2... I tried to implement my own checkbox implementation but did not work, the behavior is that, when you select one checkbox, another one gets deselected and that keeps going... It happens to all checkbox implementations on TreeTable's within JDev 11gR2...

Tested with your sample and with my own implementation =/

PS: You have a really hard captcha!!! Tried around twenty times before posting successed

Andrejus Baranovskis said...

Okej, I will test it and check for workaround solution.

Andrejus

Andrejus Baranovskis said...

Hi,

I have tested - indeed it didnt worked on new release.

But I fixed it and found working solution. I will post update on the blog.

Andrejus

Renan Monteiro's Sharepoint said...

Hello Andrejus,

Thanks for you help! I'll be waiting.



Regards,
Renan.

Andrejus Baranovskis said...

Hi,

I have posted updated sample app: http://andrejusb.blogspot.com/2012/11/check-box-support-in-adf-tree-table.html

Andrejus

srikala A said...

I have a requirement where we have to display around 10 checkboxes on a page. Based on the checkboxes selected, we need to display the text of those checkboxes in the format of a table. So, can you please help.

Thanks
Srikala