ADF 11g – the native AutoSuggest behavior

Lucas Jellema 4

The recent ADF 11gR1 PS1 release introduced a component we have been waiting for: the inputText with AutoSuggest. An inputText component that will present suggested values to the user depending on whatever text the user has already entered. The implementation in ADF of the functionality that got AJAX started, based on the original Google Suggest feature:


The auto suggest mechanism in ADF is not so much a new input component as it is a behavior (component) that can be added to inputText components. By adding the properly configured autoSuggest to an inputText, it is turned into an inputText with autoSuggest:

<af:inputText label="Country" value="#{}"
              columns="20" id="it5">
  <af:autoSuggestBehavior suggestedItems="#{countrySuggester.getCountries}"/>

Here we have added the autoSuggestBehavior to an inputText that is used for entering a country. Of course we could have used a dropdown component, combobox or list of values. However, the auto suggest is somewhat more light weight and elegant especially when our collection of countries is far from complete, and we only have a limited number of suggestions to offer – and we certainly would not want to suggest that the user can only choose from the values we are proposing.


When the input text has focus, a list of suggested values is presented. As soon as the user has typed a character, a filtered list of suggested values is presented. Well, that seems the obvious thing to do. However: what items are presented as suggested values is entirely up to us! The autoSuggestBehavior component is really nothing but a fairly fancy UI component. It does not filter, sort, suggest etc on its own accord. Everything that has to do with what values are suggested, how many of them and in what order must be programmed by us ourselves, in the method referred to by the attribute suggestedItems. If you only want to show suggestions when the user has typed at least 3 characters: again, you write that logic into the suggesteditems method.

The autoSuggestBehavior can be used whenever and wherever an inputText component can be used, for example inside a table:


Or inside a Carousel:


Note that the list of suggested values supports:

  • traversing the list by using the up and down arrow, starting with down arrow when the focus is still on the inputText component (it does not wrap around – i.e. when on the last item, typing down does nothing; it does not make the first item in the suggested values list the selected on)
  • selecting a suggested value from the list (either with mouse or enter key) and thus applying that value to the inputText component


Also note that since we control whatever values are shown in the suggested values list, we probably can find slightly alternative ways of using this functionality whereby the suggested values are not necessarily based on the alphabetic filtering of a predefined list based on the exact string entered by the user.

Implementing Auto Suggest Behavior

The only thing we need to do in order to implement the auto suggest functionality, apart from adding the autoSuggestBehavior tag to the inputText component of choice, is implement the method that returns the the suggested values. This method needs to have this signature:

 public List<SelectItem> methodName(String currentValueInInputText)

This method is entirely responsible for determining the values to be presented, the number of them, the order of them etc.

The suggested list of countries is produced by the countrySuggester bean:

public class CountrySuggester {

  private List<SelectItem> countries = new ArrayList<SelectItem>();

  public CountrySuggester() {
    countries.add(new SelectItem("Belgium"));
    countries.add(new SelectItem("Bulgaria"));

  public List<SelectItem> getCountries(String country) {
    List<SelectItem> items = new ArrayList<SelectItem>();
    for(SelectItem item:countries){
      if (item.getLabel().startsWith(country)) {
    return items;


Download JDeveloper Fusion Application: DemoAppWithAutoSuggest.

4 thoughts on “ADF 11g – the native AutoSuggest behavior

  1. Is there any way to provide the listener for the selected item for the autosuggested list as I need the selected item label and also value?
    Any reference or any working example is really helpful.

  2. This looks like exactly what I’ve been looking for. I’m curious which version of JDeveloper you are using for this “Auto Suggest” feature..? I have JDev installed and it doesn’t seem to know about this behaviour.

  3. Nice! Could the suggestedItems come from a ViewObject too? Declaratively might be difficult I suppose. Taking your example – we might not want to force the user to choose the country from our own list, as per an LOV (in case it is incomplete), but feed the suggested items from, say, a union between names in our “countries” ref table and those already entered by other users.

Comments are closed.

Next Post

ADF 11g: contextInfo to implement a common Fusion Applications pattern

Oracle Fusion Applications are on the move. They were demonstrated at Oracle Open World 2009, they are current being tested with dozens if not hundreds of organizations and they have been promised for general availability later in 2010. Screenshots of selected modules are available on the internet, for example at: […]
%d bloggers like this: