Saturday, September 10, 2016

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 




Happy Coding !!!



2 comments:

  1. really Nice explanation about problem resolving thanks to this.

    Email Appending

    ReplyDelete
  2. Borgata Hotel Casino & Spa - Mapyro
    Get directions, reviews and information for Borgata 안성 출장마사지 Hotel Casino & 충청북도 출장안마 Spa in Atlantic 강릉 출장안마 City, 화성 출장마사지 NJ. The Borgata 구리 출장샵 is the first casino to accept a casino

    ReplyDelete