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

ADF View Criteria

Here, we will see how to filter data using view criteria.
1.    Create a simple view criteria and apply on the view object to filter data.
2.    Clear the filter condition by removing the applied view criteria.
3.    Programmatically create a view criteria.
Note the following APIs related to View Criteria:
* getViewCriteria(“EmployeeViewCriteria”) — This will return the view criteria object.
* applyViewCriteria(vc) — Applies the view criteria on the view object
* removeApplyViewCriteriaName(“EmployeeViewCriteria”) — Removes the applied view criteria from the view object
1.    Create a simple view criteria and apply on the view object to filter data.
Double click the View Object on the application navigator. Select Query and add a view criteria.
vc1
As shown, select the attribute(Dept), the operator and a bind parameter.
vc2
Open the ViewImpl java file and write the following code to create a method. This method will fetch the view criteria and sets the bind parameters. Finally, executes the criteria to apply on the view object.
vc3
public void searchEmployee(String dept) {
ViewCriteriaManager vcm = getViewCriteriaManager();
ViewCriteria vc = vcm.getViewCriteria(“EmployeeViewCriteria”);
vc.resetCriteria();
this.setdept(dept);
this.applyViewCriteria(vc);
this.executeQuery();
}
Open the client interface for the View Object and select the method to be exposed in the data control.
vc4
Select and drag the searchEmployee from the data control to test1PG.jspx and select ADF Parameter Form.
vc5
vc6
Drag the EmployeeView to the page to create a table.
vc7
Run the page to test. Supply some department name and click the search button to apply the view criteria and the filtered data will be displayed.
vc8
vc10
2.    Remove the applied View Criteria
Now, write the following piece of code to create a method which will remove the criteria that we just applied.
vc11
public void clearSearchEmployee() {
this.removeApplyViewCriteriaName(“EmployeeViewCriteria”);
this.executeQuery();
}
As done earlier, expose the created method in data control.
vc12
Drag the method to the page to create an ADF button.
vc13
vc14
Run the page to test again. First, filter data by applying the view criteria. Now, clear the criteria by hitting the newly created button.
vc15
3.    Programatically create a view criteria.
Now, we will see how to create a view criteria programmatically and apply on the view object.
The following code does the work.
public void progEmployeeCriteria(String dept) {
ViewCriteria vc = this.createViewCriteria();
ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
ViewCriteriaItem jobItem = vcRow.ensureCriteriaItem(“Dept”);
jobItem.setOperator(“=”);
jobItem.getValues().get(0).setValue(dept);
vc.add(vcRow);
this.applyViewCriteria(vc);
this.executeQuery();
}
Here, Dept is the View Object attribute name and dept is the user input.
Let’s expose this method in the data control and create an ADF parameter form on the screen.
vc16

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

إرسال تعليق

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