Subject :
To find a specific row from a Row Set Iterator using findByKey() and setting the row as a current Row to a specific view object
Solution#1 - To get a specific row in Application Module Impl class
//Primary key value , Specify the data type accordingly
String empID= "EMP001";
// 1. Get the View Object instance
EmployeeVO empVO = getEmployeeVO();
// 2. Create a Key object
Key key = new Key(new Object[] { empID });
//3. Get the RowSetIterator Object
RowSetIterator rsi = empVO.createRowSetIterator(null);
//4. Find the row in the Iterator using findByKey funtion by passing Key object
Row row = rsi.findByKey(key, 1)[0];
// 6. Set the Current row in Iterator (findByKey does not Navigate to current row)
rsi.setCurrentRow(row);
Solution#2 - To get a specific row in Managed Bean
//Primary key value , Specify the data type accordingly
String empID= "EMP001";
// 1. Access the binding container
DCBindingContainer bc = (DCBindingContainer)getBindings();
// 2. Find a named iterator binding
DCIteratorBinding iter =
(DCIteratorBinding)bc.findIteratorBinding("EmployeeVOIterator");
// 3. Create a Key object
Key key = new Key(new Object[] { empID});
//4. Get the RowSetIterator Object
RowSetIterator rsi = iter.getRowSetIterator();
//5. Find the row in the Iterator using findByKey funtion by passing Key object
Row row = rsi.findByKey(key, 1)[0];
// 6. Set the Current row in Iterator (findByKey does not Navigate to current row)
rsi.setCurrentRow(row);
This was a very good explanation. As a newbie to ADF, I found this clear, concise, and it solved my issue. Thanks!!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThank you man. Very clear.
ReplyDelete