How-to select multiple parent table rows and synchronize
a detail table with the combined result
import oracle.jbo.Row;
import oracle.jbo.domain.Number;
import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.RowKeySet;
public class MasterDetailBean {
//reference to the employees table used for PPR
private RichTable employeeTable;
public MasterDetailBean(){}
public void setEmployeeTable(RichTable employeeTable) {
this.employeeTable = employeeTable;
}
public RichTable getEmployeeTable() {
return employeeTable;
}
//Select listener defined for the departments table. The selected
//row keys are read from the table reference. For each row, the
//department ID value is read and added to a string buffer that
//builds a comma separated list of departmentIds. At the end, this
//String is passed as an argument to the ExecuteWithParams action
//binding
public void onDepartmentTableSelect(SelectionEvent selectionEvent) {
//variable to hold the string containing all selected row's
//departmentId value
StringBuffer departmentIds = new StringBuffer();
//get access to the master table to read selected row keys
RichTable rt = (RichTable) selectionEvent.getSource();
RowKeySet rks = rt.getSelectedRowKeys();
Iterator selectedRowsIterator = rks.iterator();
//memorize the current row key to set it back at the end
List currentRowKey = (List) rt.getRowKey();
//for each selected master row, determine the departmentId
while(selectedRowsIterator.hasNext()){
List rowKey = (List) selectedRowsIterator.next();
//each value is ended with a comma
if(departmentIds.length() > 0){
departmentIds.append(",");
}
//make the row current
rt.setRowKey(rowKey);
JUCtrlHierNodeBinding wrappedRow =
(JUCtrlHierNodeBinding) rt.getRowData();