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 


No comments:

Post a Comment