I am using jdev 126.96.36.199.0 and due to some reasons, I have disabled row selection in my table. And I have given a check box for allowing the user to select a row. If Row selection is enabled, any row on which the user clicks becomes the current row and hence can be easily accessed in code. This post shows how to access a selected row when the row selection feature is disabled.
In short, when the user clicks on the checkbox, I want to get the row on which user has clicked the checkbox.
So I use the following code in my value change listener.
FacesCtrlHierNodeBinding changedRow = (FacesCtrlHierNodeBinding)linesTable.getRowData();
and u can get any attribute from the row using changedRow.getAttribute();
DCBindingContainer bindings = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bindings.findIteratorBinding("LinesVO1Iterator");
List rowKey = (List)linesTable.getRowKey();
Key key = (Key)rowKey.get(0);
Row row = iter.findRowByKeyString(key.toStringFormat(true));
Method 3 :
BindingContext bc = BindingContext.getCurrent();
DCDataControl dc = bc.findDataControl("MyAMDataControl");
ApplicationModule am = (ApplicationModule)dc.getDataProvider();
ViewObject vo = am.findViewObject("LinesVO1");
Row row = vo.getRowAtRangeIndex(linesTable.getRowIndex());
Note : My table has a binding in this backing bean so that I can access it as linesTable variable.