This post is about a very basic question- How to set the value of view object bind variable in Oracle ADF?
and there are multiple posts about it that describe multiple ways to do this
Using setter method in VOImpl class
But Sometimes we can not assign bind variable value in a declarative way for first time execution as value source for bind variable is fixed but its value may change at runtime from n number of events
So for this type of requirement, we can set bind variable’s value in such a way so that we need not write code everywhere to set changed value.
See how can we do this –
- Create a Fusion Web Application and prepare model using Departments table of HR Schema
- Open Departments viewObject add a bind variable in its query, this bind variable is further used to set value and filter result set
- Create Java class for Department view object, go to Java tab of Departments VO and click on edit icon of Java Classes and select “Generate ViewObject Class“
- Now we can set bind variable’s value by overriding 3 methods of DepartmentVOImpl class
1. Overriding bindParametersForCollection in ViewObject java class –
This method is used to set the bind variable’s value by the framework, framework supplies an array of all bind variable to this method We can override this method to set the value of the bind variable,
Open DepartmentVOImpl class and click on override methods icon on top of the editor
It will open a window that consists of all methods, search by name and click on ok
2. Overriding prepareRowSetForQuery in ViewObject java class –
3. Overriding executeQueryForCollection in ViewObject java class –
See the Code in DepartmentsVOImpl-
Now use any one of these methods to set bind variable value and run application module, check result
It is showing data for DepartmentId 100.
Thanks, Happy Learning 🙂
An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF