Thursday, April 3, 2014

get the selected row in backing bean from af:table based on POJO?

import oracle.adf.view.rich.component.UIXTable;
import org.apache.myfaces.trinidad.model.RowKeySet;
import java.util.Iterator;

//get the table from table's binding getter method
UIXTable table = getEmployeeTable();
RowKeySet selectedRows = getEmployeeTable().getSelectedRowKeys();
Iterator selectedEmpIter = selectedRows.iterator();
while (selectedEmpIter.hasNext()) {
    Object rowKey = selectedEmpIter.next();
    table.setRowKey(rowKey);
    int index = table.getRowIndex();
    Employee row = (Employee)table.getRowData(index);
    System.out.println(row.get_empName());
    System.out.println(row.get_empNo());
}

No comments:

Post a Comment