Sometimes we need to implement custom search instead of using ADF query component.
To implement custom search form, I have used a quite beautiful way to handle search and reset functionality for a View Object.
In this post, I am taking Employees Table (Default HR Schema) to search and reset af:table.
- First, create a Fusion Web Application and create the model (EO, VO and AM) using Employees table
- Now suppose we have to search in 4 fields (EmployeeId, FirstName, Email, Salary), so for this, I have created a new read-only ViewObject from dual
- This VO from dual is created to be used as Search form on page
- Now to make search effective on Employees VO, I have created 4 bind variable for corresponding fields in Employees ViewObject
- Now I have created a ViewCriteria using these 4 bind variables to re-query ViewObject data
- This ViewCriteria will be executed each time when the value of bind variable is changed, now this is the time to set the value of bind variables, so I have dragged dual vo as a form on the page, and added 2 buttons for Search and Reset
- To View Search Result, Employees Table is there on the page
- Now to get value from Form Field to the bean, I have created binding for all 4 fields in the bean
- Now I have created ActionListener for Search button- in this code, I have to get value from the page using component bindings and passed in Employees ViewObject’s bind variable in order to execute viewCriteria.
- Once the value is set in bind variable, view criteria is executed and Search result will be shown in resultant table- Run your application and see
- To reset values in table and search form, see the managed bean code of Reset button
- Click on the reset button and page value are set to default
- This is how we can implement custom search using ADF components, you can apply validations, auto-suggest feature etc while using this custom search
An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF