Monday, April 27, 2020

Adding Boolean Checkbox to Table Component in Oracle ADF


I have seen many people asked this question at OTN forums so i decided to blog it.

In Oracle ADF  af:selectBooleanCheckbox and af:selectBooleanRadio component has Boolean datatype which is not actually SQL supported data type (In Oracle we have Boolean in PL/SQL) and most of us stores boolean column values as Y/N or 1/0 in our tables.

Solution is pretty simple you have to add transient attribute in your ViewObject and set the values to your actual attribute based the values in transient attribute

Follow these steps:

1) Add a Transient Boolean attribute in your VO
2) Generate a Java class ViewRowImpl with Accessors of your VO
3) Set your attribute's values in Transient getter and setter method

Heres the example:
Create a table called checkboxer

create table checkboxer
(date_val timestamp,
 check_status varchar2(1 char));

- Create a ADF application and add checkboxer's EOs VO and AM

- Add a Transient attribute called StatusBoolean in VO

- Generate ViewRowImpl class replace the existing code with as shown in the slide


- Thats all Run the Business component browser and check the values
- Drop a collection as ADF table and right click the StatusBoolean column and choose Convert to.. and select Checkbox boolean.

Download the workspace

Happy Jdeveloping,