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

ADF View Accessor

What is View Accessor?
It is a business component object(bc4j) which provides the access of one view object from another.
A Case Study: Lets say, we have two view objects: employeeVO and departmentVO. We have departmentId of the employee in employeeVO and we have all the department related informations in departmentVO.
Now, using departmentId, if we need other department informations from departmentVO,lets give the access of departmentVO to employeeVO. This means, we create an accessor(for departmentVO) in employeeVO. This enables us to access department related data from the employee table.
What will we do here? Lets discuss a simple example, where for every row in the employeeVO, there is a LOV for the department field which fetched data from departmentVO. Here are the things we will do..
  • We will first create a simple List of Values(LOV) using view accessor. Here, the department column in employeeVO will be a dropdown(LOV) having data from departmentVO
  • We will then create a dependent LOV. Once the above created LOV for department is selected, it will dynamically refresh the LOV for skill LOV which is dependent on the department.
  • Finally, we will see how we can programatically handle View Accessor, fetch the resultset, filter the result set, etc..
Okhay..lets start with a simple example.
We have an employeeView with a column for storing the department information. We will make the column an LOV and the list will be populated from a query(DepartmentsView).
Lets create a VO first-DepartmentsView.
va1
As shown, lets go to the ViewAccessors section in the EmployeeView.xml and add the above created DepartmentsView.
va3
va4
Lets run the application module and test EmployeeView. Our departmen LOV is ready..!
Lets now create a dependent LOV. Here we will try to make the skill column of the EmployeeView dependent on the Dept selection.
lets start creating a DeptSkillVO which tells about various skills required in departments.
va6
We’ll add a view criteria to filter DeptSkillVO data for a given department. Let department be a bind variable.
va7

We have to create a view accessor for DeptSkillVO for EmployeeView. Select the VOCriteria while creating the accessor. Lets assign the Dept attribute to the bind variable. By doing this, we pass the dept selection to the view criteria for DeptSkillVO which would yield the corresponding skills for that department.

va8
You know what..we are ready to test.

Now, we will see how we can work programmatically with a View Accessor.
Lets create a VO: CLDeptDescVO as below and create an accessor in EmployeeView.xml.
va9

va5
Now, we will create a transient attribute DeptDesc which tells about the department we selected. We are trying to programmatically show the DeptDesc through getDeptDesc() method in EmployeeViewRowImpl.
va11
Lets paste the following lines for getDeptDesc() in EmployeeViewRowImpl.

public String getDeptDesc() {
RowSet rowSet = this.getCLDeptDescVO1();
rowSet.setRangeSize(-1);
System.out.println(“Row Dept:”+this.getDept());
rowSet.setNamedWhereClauseParam(“deptBind”, this.getDept());
rowSet.executeQuery();
Row deptRow = rowSet.first();
System.out.println(“Dept No”+deptRow.getAttribute(“Development”));
return deptRow.getAttribute(“Development”).toString();
//        return (String) getAttributeInternal(DEPTDESC);
}
va10
We are ready to test!!
Given below is a sample output for the above tests.
va12

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

إرسال تعليق

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...