Hello All
Hope Everyone knows about the list of values and autoSuggest behavior of ADF Framework, In this post I’ll show you how to implement contains or ends with behavior in autosuggest.
For those who are new to the framework can look at this post
ADF Basics: Implementing auto suggest behavior in ADF Faces lov (list of values)
By default autoSuggest search behavior is “STARTSWITH” means when a user types any string in input part of lov then framework shows all suggestion that starts with the input string
Now the requirement is to change the default behavior of autoSuggest search so for this I have googled it and found two wonderful posts of Andrejus Baranovskis (Thanks)
Suppressing ADF LOV Like Operator Filtering
Suppressing ADF LOV Like Operator Filtering V2
These both post talk about another problem with lovs that opens search popup for suggested values and Andrejus uses a solution that overrides lov view criteria operator to not to show any suggested values.
I have used the same method to override lov auto-suggestion view criteria operator to implement contains behavior
Here I have applied Departments Lov on Employee viewObject’s Department Id attribute and default autoSuggest behavior is like this
In the above blog posts, it is mentioned that framework executes view criteria named __lov__filterlist__vcr___ to retrieve suggested values so to override this view criteria create ViewObjectImpl class of Departments ViewObject (LOV ViewObject) and override applyViewCriteria method and used the same method to override lov operator
See this code here I am using CONTAINS operator in place of STARTSWITH
@Override public void applyViewCriteria(ViewCriteria viewCriteria, boolean b) { super.applyViewCriteria(supressLikeOperatorForLov(viewCriteria), b); } private ViewCriteria supressLikeOperatorForLov(ViewCriteria vc) { //Check for VC name, If cirtera is executed for suggested values if (vc != null && vc.getName().toLowerCase().contains("__lov__filterlist__vcr___")) { //Get current row of ViewCriteria (Current operation) ViewCriteriaRow row = (ViewCriteriaRow) vc.getCurrentRow(); if (row != null) { //Get criterai items ArrayList criteriaItems = (ArrayList) row.getCriteriaItems(); for (int i = 0; i < criteriaItems.size(); i++) { ViewCriteriaItem criteriaItem = (ViewCriteriaItem) criteriaItems.get(i); if (criteriaItem != null) { if ("STARTSWITH".equals(criteriaItem.getOperator())) { //Change STARTSWITH operator to CONTAINS criteriaItem.setOperator("CONTAINS"); } } } } } return vc; }
And see how this works, For the same input, it shows all that suggested values that contains ‘S’
In the same way, we can implement other operators too, just replace CONTAINS with ENDSWITH and see the result
Cheers 🙂 Happy Learning
Excellent post, very helpful.
Thanks for this post sir , How can we hide input lov search dialog as I don't want user to open this
Hi Abhinav
You can hide search icon using ADF Skin check this – ADF Skinning | Hiding search icon of af:inputListOfValues using CSS & StyleClass
Ashish
I wish you die in the most painful way
May u live long ashish
Wow its good, u r always awesome every problem can be resolved by ur post, I wish u live long and keep posting like dis thanks..
Thanks very much , ur enemies may die by seeing it again and again.
Being anonymous means the person doesn't have courage for his own shit, I wish for your well being
We love you, you're doing a great job
Thank you friends for your love and support 🙂
I started reading ur blog
Good Articles, offering help to more people
Just Keep going forget about others