Instead of iterating a
View Object using a
RowSetIterator - as described in
Bit #4 - Iterating a View Object using a secondary RowSetIterator, you can locate a row directly using the
ViewObject method
findByKey(). This will work as long as you indicate a
View Object attribute as a
Key Attribute. To use this method, you will need to first instantiate a
jbo.Key object and then pass it as an argument to
findByKey().
findByKey() will return an array of rows that match the
Key object. Special attention should be given when constructing
Key objects for multi-part keys and for
View Objects that are based on more than one
Entity Objects. These cases are explained in detail in the
Oracle Fusion Middleware Java API Reference for Oracle ADF Model documentation referenced below.
Example:
// in the context of the ApplModuleImpl
// locate the employee's department
Number departmentId =
((EmployeesRowImpl)(this.getEmployees().getCurrentRow())).getDepartmentId();
Key keyDepartment = new Key(new Object[] { departmentId });
// the second argument indicates the maximum number of rows to return
Row[] departments = this.getDepartments().findByKey(keyDepartment, 1);
if (departments != null && departments.length > 0) {
DepartmentsRowImpl department = (DepartmentsRowImpl)departments[0];
// you can access the Department's attributes here....
}
Context:
Application Module Implementation Class
View Object Implementation Class
Reference:
Oracle Fusion Middleware Java API Reference for Oracle ADF Model, findByKey