Friday, December 11, 2015

ADF Table Filter Case Insensitive and Search by Contains Instead of Start With

In ADF table if you enable column filter this filter by default will search by "start with" and it will be case sensitive . For example in table employees if you have employee name = Hermann and you try to search by "man", the search will return no result


but if you search by "Herm" it will return result


If you try to search by "herm" it will return no result.



This is because the filter by default is case sensitive and will search by start with.

In many cases we need the all tables filters be case insensitive and search by contains not start with. You can search by case insensitive by setting filterFeatures="caseInsensitive" for  each af:column but you need to do this in all af:column in your application and it will not be a proper solution.

You can search with contains by typing your string between '%', but we need something to be more easy than typing %.

To make the the ADF table filter be case insensitive and search by contains follow these steps:

1- In model project create new class "CustomViewImpl" this class should extend oracle.jbo.server.ViewObjectImpl


2- In this class override getCriteriaItemClause(ViewCriteriaItem viewCriteriaItem) and write this code:





3- Go to Model --> Project Properties --> ADF Business Components --> Base Classes --> View Object --> change Object to point to your CustomViewImpl class


4- Open ViewObject --> Java --> Java Classes --> Generate View Object Class



5- If you open the generated ViewImpl class you will find it extend the CustomViewImpl class


6- Run the application and test.

You can download the sample application from here

(This sample developed in JDev 11.1.2.4.0)




5 comments: