Thursday, October 7, 2010

autoSuggestBehavior using Database Query

autoSuggestBehavior is new addition in oracle ADF 11g used to display suggestedItems in a drop down box for an editable component in webpage based on user input on that. In this post what I am trying to show is an implementation of autoSuggestBehavior. Weblog for the AMIS Technology corner has a very good post for that. I am trying to leverage database persistence with autoSuggestBehavior. Data which is displayed as suggestedItems can be taken from backing bean (we can refer ( for that methodology) or we can use data from database tables. In this post I have implemented that.

Below is the output of that implementation.

I have created a SQL script for creating country table and inserting values to that table. Please refer for downloading that script.

To achieve this only unlike other ADF projects we need not to create any Entity object, view object, Application Module. We can directly start working on webpage. As discussed earlier autosuggestBehavior shows suggestedItems for editable component in webpage. So we have used an inputText and attach viewscope managed bean procedure to the suggestedItems.

The Procedure is as follows

Used getCountries () procedure is as follows

I have used JDBC connection from managed bean to retrieve all country details. Below procedure is used for that.

Above method shows the Implementation without using any ADF Components like Entity, View, and ApplicationModule. But we can achieve same using a view object named "CountryEntityObjectView" and expose that view in Application Module. So that It will reflect in data control.

After that we need to create an Iterator in Page Definition file like below

Make sure that Its Range Size is Sufficient enough to capture all country names. We need to use this Iterator in our Managed Bean Procedure for suggestedItems (showed in 3rd Screen Shot here) as below

download link for Managed Bean java code is , for webpage is for page definition file is


  1. Hi,

    Nice but probably more easy and declarative way is

  2. Biag,
    That link is also a cool stuff. whatever shown here using Snapshot and docs you have explained that using video in that blog.

    Really nice one.