How to
get a selected row from af:table component in backing bean
This might be very common requirement for any ADF developer , to
get a selected row(s) from <af:table> component in a backing bean.
// Table Binding
<af:table value="#{bindings.EmpVO.collectionModel}" var="row"
rows="#{bindings. EmpVO .rangeSize}"
emptyText="#{bindings. EmpVO .viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings. EmpVO .rangeSize}"
rowBandingInterval="0"
rowSelection="multiple" id="t1"
styleClass="AFStretchWidth" columnSelection="multiple"
first="0" contentDelivery="immediate" autoHeightRows="10"
binding="#{pageFlowScope.ExampleBean.employeeTable}">
Below approach is advisable, If multiple selection rows required
// Table Binding
<af:table value="#{bindings.EmpVO.collectionModel}" var="row"
rows="#{bindings. EmpVO .rangeSize}"
emptyText="#{bindings. EmpVO .viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings. EmpVO .rangeSize}"
rowBandingInterval="0"
rowSelection="multiple" id="t1"
styleClass="AFStretchWidth" columnSelection="multiple"
first="0" contentDelivery="immediate" autoHeightRows="10"
binding="#{pageFlowScope.ExampleBean.employeeTable}">
Below approach is advisable, If multiple selection rows required
// Get the instance for table component in
backing bean
UIXTable table = getEmployeeTable();
// Get the Selected Row key set iterator
Iterator selectionIt =
table.getSelectedRowKeys().iterator();
while(selectionIt.hasNext()){
Object
rowKey = selectionIt.next();
table.setRowKey(rowKey);
int index
= table.getRowIndex();
FacesCtrlHierNodeBinding row =
(FacesCtrlHierNodeBinding) table.getRowData(index);
Row selectedRow = row.getRow();
}
-- Below approach is advisable if there is only single row selection is enabled.
// Get the instance for table component in
backing bean
UIXTable table = getEmployeeTable();
// Get the Selected Row key set iterator
Iterator selectionIt =
table.getSelectedRowKeys().iterator();
while(selectionIt.hasNext()){
Object
rowKey = selectionIt.next();
table.setRowKey(rowKey); int index =
table.getRowIndex();
FacesCtrlHierNodeBinding row =
(FacesCtrlHierNodeBinding) table.getRowData(index);
Row selectedRow = row.getRow();
}
No comments:
Post a Comment