Monday, 8 January 2018

Oracle ADF Step by Step Dependent LOV

Oracle ADF Step by Step Dependent LOV:

Create DepartmentsRVO
  SELECT DEPARTMENT_ID,DEPARTMENT_NAME FROM DEPARTMENTS
Create EmployeeRVO
  SELECT EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,DEPARTMENT_ID FROM EMPLOYEES
DeptEmpRVO
  SELECT NULL DEPARTMENT_ID,NULL EMPLOYEE_NAME,NULL INFO FROM DUAL

Added DeptEmpRVO into AM.
Double click on EmployeesRVO, Select ViewCriteria, Click on + for Add New, Click on Add Item,
Select DepartmentId, Equals, BindVariable, Click on + Parameter, enter DepartmentIdBind, click on Ok.

Double click on DeptEmpRVO, Select Attributes,
select DepartmentID attribute, click on Listofvalues, select DepartmentRVO for LOV
Configuration: ViewAttribute:DepartmentID ListAttribute: DepartmentId
UI Hints: Default List Type: Input Text with List of Values.
Select Department Name.

Double click on DeptEmpRVO, Select Attributes,
Select EmployeeId attribute, click on listof values, select employeeRVO for LOV.
Select Accessors, Select employeeVO1, Click on Edit, select Available ViewCriteria, click on Select.
(Select value as DepartmentId.)

Create following method in AMImpl.
    public void setDepartmentIdSessionData(int dId) {
        System.out.println("*** DepartmentId="+dId+" ***");
        this.getSession().getUserData().put("DeptIdSessionValue",dId);
    }
Add above method into Client Listener, and add the method as MethodAction in Current page Bindings.
    public void execDeptId(String valueChangeEvent) {
    BindingContext bctx = BindingContext.getCurrent();
           BindingContainer bindings = bctx.getCurrentBindingsEntry();
           OperationBinding op =
               (OperationBinding)bindings.getOperationBinding("setDepartmentIdSessionData");
           int deptId=Integer.parseInt(valueChangeEvent);
           op.getParamsMap().put("dId",deptId);
           op.execute();
    }

    public void DepartmentIDVCE(ValueChangeEvent valueChangeEvent) {
        System.out.println("DepartmentIDVCE="+valueChangeEvent.getNewValue());
        execDeptId(valueChangeEvent.getNewValue().toString());
    }

Double click on EmployeeRVO, select Attributes, Click on Source, Select DepartmentID,
ViewAttribute="DepartmentId"
GenerateIsNullClauseForBindVars="false"
ContentStyle: width:200px;





No comments:

Post a Comment