23 September, 2013

ADF : Working with ViewCriteria

View Criteria's are additional where clause added at runtime to base View Object Query.


 Programmer can create view criteria declaratively or programatically.

1. Create View Criteria Declaratively Open View Object in Edit and in "Query" tab you can click "+" add pencil to create new view criteria

 
2. Control View Criteria Programatically.


 a- Get View Criteria from View Criteria manager within View Object and then apply it  
ViewCriteria applyVC = myViewObject.getViewCriteria("MyViewCriteriaName");
myViewObject.applyViewCriteria(applyVC);
myViewObject.executeQuery();

b- Applying Multiple view Criteria's

 
When multiple view criteria's are applied to the view object, the view criterias gets appended or replaced depending upon the way you use applyViewCriteria API
Replacing Existing view criteria's :

 
myViewObject.applyViewCriteria(applyVC) or

myViewObject.applyViewCriteria(applyVC,false)
will erase all previously applied view criterias and apply the current view criteria only.
Appending to the Existing view criteria:


myViewObject.applyViewCriteria(applyVC, true) 

 Will append this view criteria to the existing view criteria(s) which is applied already.

c- Unapplying && Removing View Criteria

vo.removeApplyViewCriteriaName()
Unapply the view criteria if it is applied. The view criteria will still remain in View Criteria Manager (which means you can't apply this view criteria whenever you require in the future).
vo.removeViewCriteria()
Removes the view criteria from View Criteria Manager. If it is applied it is first unapplied and then removed. (which means you cant apply this View Criteria to the view object next time in the future.).


For example the below code returns null after removeViewCriteria has been applied.
ViewCriteria applyVC = myViewObject.getViewCriteria("
MyViewCriteriaName")

vo.clearViewCriterias()
Unapplies and removes all view criteria, both applied and unapplied from View Criteria Manager. Which means that you can't apply any View Criteria against View Object.
For example the below code returns null after clearViewCriterias() has been applied.
ViewCriteria applyVC = myViewObject.getViewCriteria("
MyViewCriteriaName")
myViewObject.applyViewCriteria(null)
The above statement unapplies all existing View Criterias and not remove it.



myViewObject.setNamedWhereClauseParam("MyParameter", "myValue)
The above statement set Named Parameter Value. It set the value of "MyParameter" to "myValue".

I post in previous post about  ADF : Change View Criteria Columns at Runtime

Thanks
Recommended Post Slide Out For Blogger