This post is about a very basic question- How to set value of view object bind variable in Oracle ADF?
and there are multiple posts about it that describes 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 to 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 it’s query , this bind variable is further used to set value and filter result set
- Create Java class for Department view object, goto 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 bind variable’s value by framework, framework supplies an array of all bind variable to this method We can override this method to set value of bind variable ,
Open DepartmentVOImpl class and click on override methods icon on top of editor
It will open a window that consist 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 anyone of these methods to set bind variable value and run application module, check result
It is showing data for DepartmentId 100.
Thanks, Happy Learning 🙂
I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF