Implement contains/endswith behavior in model based autoSuggest Lov (Input list and combo box)

Sharing is Caring

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

 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
return vc;

And see how this works, For the same input, it shows all that suggested values that contains ‘S’

Implement contains

In the same way, we can implement other operators too, just replace CONTAINS with ENDSWITH and see the result

Cheers 🙂 Happy Learning

Related Posts

10 thoughts on “Implement contains/endswith behavior in model based autoSuggest Lov (Input list and combo box)”

  1. Thanks for this post sir , How can we hide input lov search dialog as I don't want user to open this

  2. 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

Leave a Reply

Your email address will not be published. Required fields are marked *