Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Wednesday, November 21, 2012

ADF 11g: Getting Selected values from a LOV

I had a table in the UI where one of the column is a LOV. The requirement was to default another field say PayeeName in the  same row based on value selected from the LOV only when the PayeeName field does not have a value already.

To accomplish that the simplest idea is to bind the ReturnPopupEvent to a managed bean method and some how get one of the returned value from LOV in this method. Then check if the PayeeName field is null. If yes then update it otherwise just ignore. This can be done quite easily as follows:

1. Go to the ReturnPopupEvent property of the LOV and bind it to a manged bean method.
2. In the bean method you can write the code as below:


public void myLOVListener(ReturnPopupEvent returnPopupEvent) {    
        List lst= (List)returnPopupEvent.getReturnValue();
       String value = null;
       for(Object obj : lst{
                        value  = ((Map)obj).get("RoleName"));
                       if(value != null)
                           break;
        }
     
//get the iterator binding to get handle of the current row    
  DCBindingContainer bc =
            (DCBindingContainer)BindingUtils.getBindingContext().getCurrentBindingsEntry();
        DCIteratorBinding profItr =
            bc.findIteratorBinding("MyTableVOIterator");
        Row rw = profItr.getViewObject().getCurrentRow();
        if(rw != null &&  rw.getAttribute("PayeeName") == null){
            rw.setAttribute("PayeeName", value);
        }
    }


Please note that I am not really checking for null etc. as my intention is just to show how to use returned values from the returnPopupEvent.


Another important point to note down is that the LOV must have RoleName as one of the return attributes in its configuration in the model.
Post a Comment