Tuesday, May 5, 2020

Set current row programmatically for af:table programmatically from managead bean using POJO

Set POJO table current row 

One of the ways to set current row is 

//Table binding
private RichTable tableBinding;


 RowKeySet rowKeySet = tableBinding.getSelectedRowKeys();

 rowKeySet.clear();
 //Add row index in rowKeySet.add();
 //rowKeySet.add();
 SelectionEvent selectEvent = new SelectionEvent(tableBinding.getSelectedRowKeys(), rowKeySet, tableBinding);
selectEvent.queue();

A  POJO based table is created and setting the current row when we add a item.

1.Person Object is created with first name , last name and middle initials



2. Create a managed bean for af:table, this managed bean uses Person Object to add data to table ,A List with person is used to add data. I have declared first name, last name and middle initials to bind to input value .


3.Drag and drop af:table from component palette ,keep necessary columns and in Value attribute of table bind with List<Person> and change column output text values .



4. Add a button , bind input text values with bean first name, last name and middle initials references . Add action listener for button in bean.


5. In action listener we will add the values from first name, last name and middle initials to personList and set current programmatically. 


Run the application 






As current row is set for the last added person added , that person detail row is highlighted here 


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,