Search in LOV dialog window, by default is not case insensitive. You could define View Criteria for LOV VO with case insensitivity and select this criteria to be displayed in LOV dialog. You could do this for one or two, may be for ten LOV's - but I'm sure you are going to get tired pretty soon. Much more effective is to implement generic solution to convert LOV search criteria to be UPPER case automatically.
I'm using sample application from my previous post about dynamic ADF BC and new dynamic ADF UI component in ADF 12c - ADF Dynamic ADF BC - Loading Multiple Instances (Nr. 100 in 2013). The same technique as described below can be applied also for design time ADF BC, across different ADF versions. Download sample application, updated for this post - ADFDynamicReportUI_v6.zip.
Default search dialog is case insensitive, you could test it quite easily. Try to search for lower case value, when you know there are upper case matching values - there will be no results:
SQL query is generated with a WHERE clause as it should, it is trying to search for matching values - but there are no such records in DB:
We could solve it with generic class - our custom View Object implementation class. My sample is using dynamic ADF BC, so I register this custom class programmatically with VO instance (typically you could do it through the wizard for design time ADF BC):
As I mentioned above, sample application is using ADF UI dynamic component, however the same works with regular ADF UI also - it doesn't matter:
Here is the main trick how to make search from LOV dialog to be case insensitive. You must override buildViewCriteriaClauses method in View Object implementation class. If current VO instance represents LOV (if you don't want to rely on naming convention, you could create additional View Object implementation class, intended to use only for LOV's), we should invoke setUpperColumns method applied for View Criteria. This converts entire View Criteria clause to use UPPER for both criteria item and bind variable:
Now with automatic conversion to UPPER case, try to execute the same search - you should see results:
View Criteria clause is constructed with UPPER and this is why it allows to perform case insensitive search. Of course, for runtime DB performance optimisation, you need to make sure there is functional index created for searchable columns:
The same works for any number of View Criteria items. Here I search using both attributes:
View Criteria clause contains both attributes and both are changed to use UPPER - this is perfect:
Case insensitive auto completion works as well with the technique described above. Try to type a value, existing in LOV - but with lower case (it_prog):
Such value is located and is automatically changed to use the case as it is originally stored in DB (IT_PROG):
View Criteria clause was constructed with UPPER in the case of auto completion as well as with regular search in LOV dialog:
I'm using sample application from my previous post about dynamic ADF BC and new dynamic ADF UI component in ADF 12c - ADF Dynamic ADF BC - Loading Multiple Instances (Nr. 100 in 2013). The same technique as described below can be applied also for design time ADF BC, across different ADF versions. Download sample application, updated for this post - ADFDynamicReportUI_v6.zip.
Default search dialog is case insensitive, you could test it quite easily. Try to search for lower case value, when you know there are upper case matching values - there will be no results:
SQL query is generated with a WHERE clause as it should, it is trying to search for matching values - but there are no such records in DB:
We could solve it with generic class - our custom View Object implementation class. My sample is using dynamic ADF BC, so I register this custom class programmatically with VO instance (typically you could do it through the wizard for design time ADF BC):
As I mentioned above, sample application is using ADF UI dynamic component, however the same works with regular ADF UI also - it doesn't matter:
Here is the main trick how to make search from LOV dialog to be case insensitive. You must override buildViewCriteriaClauses method in View Object implementation class. If current VO instance represents LOV (if you don't want to rely on naming convention, you could create additional View Object implementation class, intended to use only for LOV's), we should invoke setUpperColumns method applied for View Criteria. This converts entire View Criteria clause to use UPPER for both criteria item and bind variable:
Now with automatic conversion to UPPER case, try to execute the same search - you should see results:
View Criteria clause is constructed with UPPER and this is why it allows to perform case insensitive search. Of course, for runtime DB performance optimisation, you need to make sure there is functional index created for searchable columns:
The same works for any number of View Criteria items. Here I search using both attributes:
View Criteria clause contains both attributes and both are changed to use UPPER - this is perfect:
Case insensitive auto completion works as well with the technique described above. Try to type a value, existing in LOV - but with lower case (it_prog):
Such value is located and is automatically changed to use the case as it is originally stored in DB (IT_PROG):
View Criteria clause was constructed with UPPER in the case of auto completion as well as with regular search in LOV dialog:
4 comments:
Hi andrejus,
Thanks for sharing your knowledge. I have following question which is not exactly related to this post content.
Q: Is there a way we can give auto suggest behavior for the components in a search criteria?
Regards!
Sameera
I would need to check this.
Andrejus
Worked!! Thanks
you could define View Criteria for LOV VO with case insensitivity and select this criteria to be displayed in LOV dialog
Can you upload a tutorial for this?
How to pass the search term to view criteria?
Post a Comment