Skip to main content

Custom LOV with AutoSuggest implementation in ADF

Prerequisites of this implementation :
  1. ViewObject (in the example it is "MyViewObject")
  2. Some utility is used in the example, check my other blogs "ADF  Utility"
#1. Create LOV Listener class

This class will open the LOV window in a popup and also when user selects a row and click OK in the popup, it will set the value property of the input Text ui component where this LOV is invoked from.

// Add the getters and setters of all the class level attributes.
// I have removed them from this example to shorten the length of the blog.
// For "getUIComponent()" check my other blog to find a UI Component from managed bean
public class MyLOVListener {
     * ID of the popup where af:table is defined
    private String popupId;
     * ID of the inputText component where the selected value
     * from the popup should be copied back
    private String inputTextId;
     * Name of the iterator defined the in pagedef, from which the selected row
     * can be read
    private String iteratorName;
     * Name of the attribute of the view object which should be read and copied
     * back to the "inputText" component
    private String attributeName;
     * Name of the view object
    private String viewObjectToQuery;
    public void openLOV(ActionEvent actionEvent) {

        ViewObjectImpl lovViewObject = (ViewObjectImpl) Constants.getService().findViewObject(getViewObjectToQuery());
        RichPopup.PopupHints ph = new RichPopup.PopupHints();

    public void setSelectedRow(DialogEvent dialogEvent) {

        if(dialogEvent.getOutcome() == DialogEvent.Outcome.ok) {
            DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding dcItteratorBindings = bindings.findIteratorBinding(getIteratorName());
            ViewObject voTableData = dcItteratorBindings.getViewObject();    
            // Get selected row
            Row rowSelected = voTableData.getCurrentRow();    
            if (rowSelected != null) {
                RichInputText inputTextBox = (RichInputText)getUIComponent(getInputTextId());
                AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();


Declare this class as a taskFlow managed bean

<managed-bean id="__7">
      <managed-bean-name id="__8">MyLOVListener</managed-bean-name>
      <managed-bean-class id="__6">com.view.beans.MyLOVListener</managed-bean-class>
      <managed-bean-scope id="__5">pageFlow</managed-bean-scope>

#2. Managed bean for auto suggest behaviour :

public class MyAutoSuggestionListener {
    public List getEmployees(String employee) {
        List<SelectItem> matchingItemsList = new ArrayList<SelectItem>();
        if(employee != null) {
            matchingItemsList = getMatchingItems(getService().getMyViewObject(), "employee", employee);
        return matchingItemsList;

  private ApplicationModuleImpl getService() {
      return ((ApplicationModuleImpl)AppModuleBean.getService(FacesContext.getCurrentInstance(), "MyAppModule"));

    private List getMatchingItems(ViewObjectImpl viewObject, String attributeName, String stringToMatch) {
        List<SelectItem> matchingItemsList = new ArrayList<SelectItem>();
        for (Row row : viewObject.getAllRowsInRange()) {
            String matchingEntries = (String)row.getAttribute(attributeName);
            if(matchingEntries.toUpperCase().startsWith(stringToMatch.toUpperCase())) {
                matchingItemsList.add(new SelectItem(matchingEntries, matchingEntries));
        return matchingItemsList;

Declare this class as a taskFlow managed bean

 <managed-bean id="__9">
      <managed-bean-name id="__16">MyAutoSuggestionListener</managed-bean-name>
      <managed-bean-class id="__15">view.beans.MyAutoSuggestionListener</managed-bean-class>
      <managed-bean-scope id="__14">pageFlow</managed-bean-scope>

#3. Add input Text for the LOV :

<af:inputText simple="true" id="employeeIt1" columns="25">
                      <af:autoSuggestBehavior maxSuggestedItems="40"
                    <af:spacer id="sp1" width="3"/>
                    <af:commandImageLink id="empPopup" icon="/common/images/details.png"
                                         immediate="true" partialSubmit="true"
                        <af:setPropertyListener from="employeeIt1" to="#{pageFlowScope.MyLOVListener.inputTextId}" type="action"/>
                        <af:setPropertyListener from="employeePopup" to="#{pageFlowScope.MyLOVListener.popupId}" type="action"/>
                        <af:setPropertyListener from="MyViewObjectIterator" to="#{pageFlowScope.MyLOVListener.iteratorName}" type="action"/>
                        <af:setPropertyListener from="employee" to="#{pageFlowScope.MyLOVListener.attributeName}" type="action"/>
                        <af:setPropertyListener from="MyViewObject" to="#{pageFlowScope.MyLOVListener.viewObjectToQuery}" type="action"/>

In the above command image link : the icon used is a spy glass, which normally used by ADF in case of LOV in a popup.

#4. Add the popup for LOV in the page:

First define a af:popup element in the page like below :
<af:popup autoCancel="disabled" childCreation="immediate" id="employeePopup">
 <af:dialog id="employeeDialog" dialogListener="#{pageFlowScope.MyLOVListener.setSelectedRow}">


Then drag and drop the view object from DataControls panel in JDeveloper. Make sure you display it as a read only table. It will look like below :

<af:popup autoCancel="disabled" childCreation="immediate" id="employeePopup">
                    <af:dialog id="employeeDialog"
                      <af:table value="#{bindings.MyViewObject.collectionModel}"
                                emptyText="#{bindings.MyViewObject.viewable ? 'No data to display.' : 'Access Denied.'}"
                                rowSelection="single" id="t1">
                        <af:column sortProperty="#{}"
                                   id="c2" width="400">
                          <af:outputText value="#{row.employee}" id="ot1"/>

This implementation has some advantages :
  1. If you implement ADF managed LOVs, if the view object returns 0 rows, it throws NullPointer Exception. But this implementation will open an empty table in the popup.
  2. This implementation is reusable in the same taskFlow for multiple other LOV implementations. You only need to add one extra method in MyAutoSuggestionListener and follow #3 and #4 step for the new LOVs. The LOV listener class is robust enough to handle any new calls.


Popular posts from this blog

Secure your Node/Express REST APIs using Passport JS

Recently I have been involved in various discussions on how to make the REST APIs as secure as SOAP.
First of all, let me start with a very basic statement, about security, it doesn't depend on your Webservice type, be it REST or SOAP, your design decisions depicts whether they can be made secure or not.
In this example blog, I will use "Micro CRUD services for Oracle Database Cloud" APIs and implement (read attach) Passport's "local" authentication strategy, to make them secure.

Code in Github : LeasifyAPIs with Passport

What is Passport JS? (from Documentation)

Passport is authentication middleware for Node. It is designed to serve a singular purpose: authenticate requests. When writing modules, encapsulation is a virtue, so Passport delegates all other functionality to the application. This separation of concerns keeps code clean and maintainable, and makes Passport extremely easy to integrate into an application.

What are "strategies" in P…

ADF Utility : Find UIComponent from Managed Bean

Many a times, it is required to find an UIComponent from ADF managed bean, to do something with it, for example : change the value of an af:outputText, change readOnly property of an af:inputText etc.

private UIComponent getUIComponent(String id) { 

        FacesContext facesCtx = FacesContext.getCurrentInstance(); 
        return findComponent(facesCtx.getViewRoot(), id);

    private UIComponent findComponent(UIComponent base, String id) {

        if (id.equals(base.getId())) {
            return base;

        UIComponent children = null;
        UIComponent result = null;
        Iterator childrens = base.getFacetsAndChildren();
        while (childrens.hasNext() && (result == null)) {
            children = (UIComponent);
            if (id.equals(children.getId())) {
                result = children;
            result = findComponent(children, id);
            if (result != null) {

Chatbots and Oracle Cloud Services

Thanks to Oracle A-Team, I had a chance to work with Chatbots.
3 pure NodeJS applications, on couple of Oracle Cloud platforms and Facebook messenger, and my chatbot was running.

Let me explain, the architecture a bit. To start with, following is the simple representation of how it works.