الثلاثاء، 7 أبريل 2020

Single Row selection in Oracle ADF

Please note that I am using Department and Employee tables from HR.
Objective: After this small exercise, we would have created a department page, where we can select a department and navigate to the employee page to find employees of the corresponding department.
Let’s start with creating view objects (for Departments and Employees). No, we are not using master-details relationship here, just two view objects.
Let’s follow these steps now!
  1. Create jsf(Containing a table of departments)1.png
  2. jsf(Containing a table of employees)2.png
  3. Let’s set the navigation between the two pages.3.png
  4. Let’s create a managed bean and a method for the Navigation button’s action.4.png
  5. We will use the below set of code lines for the action’s method in managed bean.5.png
Here, the idea is to get the current row of the DepartmentsVO, which is derived from the iterator.
–Find the binding for the current page definition(Department page) :                                     DCBindingContainer bindings= (DCBindingContainer)BindingContext.
getCurrent().getCurrentBindingsEntry();


–Find the Iterator from the binding :
DCIteratorBinding dcIteratorBinding = bindings.findIteratorBinding(“DepartmentsView1Iterator”);


–Find the Departments View Object from the Iterator :                                                                 ViewObject deptVO = dcIteratorBinding.getViewObject();


–Store the departmentId of the current row in a Managed Bean variable :
this.setDeptIdParam((deptVO.getCurrentRow().
getAttribute(“DepartmentId”).toString()));


–Find the iterator for the Employees :
DCIteratorBinding dcIteratorBinding1 = bindings.findIteratorBinding(“EmployeesView1Iterator”);


–Find the Employees View Object from the Iterator :

ViewObject empVO = dcIteratorBinding1.getViewObject();

–Filter the Employees View Object based on the DepartmentId and navigate to the Employees page :

        empVO.setWhereClause(null);
        String wc = “1 = 1”;
        if(this.getDeptIdParam()!=null)
        {
        wc = wc+” AND DEPARTMENT_ID = “+this.getDeptIdParam();
        }
        System.out.println(“empVO wc”+wc);
        empVO.setWhereClause(wc);
        empVO.executeQuery();
        System.out.println(“empVO found”);
        return “FindEmps”;

ليست هناك تعليقات:

إرسال تعليق

ADF: Programmatic View Object Using Ref Cursor.

ADF: Programmatic View Object Using Ref Cursor. Posted by:  Manish Pandey   April 25, 2013   in  ADF   Leave a comment   3758 Views Sometime...