Implementing “Contains” autosuggest behavior for an Input Combo Box LOV

The framework provided autosuggest behavior performs a “Starts with” search for displaying the values in the autoSuggest of an Input Combo Box List of Values. In this post, we will see how to implement a custom autosuggest behavior which returns values by performing a “contains” search.

The following image shows an input combo box list of values dropped on a .jsff:

We can add an autosuggest behavior from the Structure window by clicking af:inputComboBoxListOfValues -> Insert inside af:inputComboBoxListOfValues -> ADF Faces -> Auto Suggest Behavior

This is the autosuggest behavior provided by the framework which returns all values which START WITH the partial string typed by the user in the input combo box list of values. We will write a custom method in the backing bean which returns the values we want to show as follows:

As seen above, this method takes a String parameter which is the partial string entered by the user and it returns a List of SelectItems which have that string as a substring. The list is retrieved in the AMImpl as follows:


In this method, we get the VO which is used to populate the input combo box list of values and apply the following view criteria on it:


The bind variable ‘Bind_ResourceName’ is set to the partial string entered by the user. By applying the view criteria we get an iterator to all the rows matching this condition, i.e. all rows where the value of “DisplayName” contains the string entered by the user.

Finally, we use the custom method from the bean instead of the framework generated suggestedItems:


Now, when the user types in the input combo box list of values, all the values containing that partial string are displayed in the autosuggest as shown:


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

ADF Tips and Tricks

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today