The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    June 19, 2011

Getting selected row in inputListOfValues returnPopupListener

Frank Nimphius
Master Principal Product Manager

Model driven list-of-values in Oracle ADF are configured on
the ADF Business component attribute which should be updated with the user
value selection. The value lookup can be configured to be displayed as a select
list, combo box, input list of values or combo box with list of values.

Displaying the list in an af:inputListOfValues component shows the
attribute value in an input text field and with an icon attached to it for the
user to launch the list-of-values dialog.

The list-of-values dialog allows users to use a search form
to filter the lookup data list and to select an entry, which return value then
is added as the value of the af:inputListOfValues

Note: The model
driven LOV can be configured in ADF Business Components to update multiple
attributes with the user selection, though the most common use case is to
update the value of a single attribute.

A question on OTN was how to access the row of the selected
return value on the ADF Faces front end. For this, you need to know that there
is a Model property defined on the af:inputListOfValues that
references the ListOfValuesModel
implementation in the model. It is the value of this Model property that you need to get
access to.

The af:inputListOfValues
has a ReturnPopupListener property that
you can use to configure a managed bean method to receive notification when the
user closes the LOV popup dialog by selecting the Ok button. This listener is not triggered when the cancel button is
pressed. The managed bean signature can be created declaratively in Oracle
JDeveloper 11g using the Edit option
in the context menu next to the ReturnPopupListener field in the
PropertyInspector. The empty method signature looks as shown below

void returnListener(ReturnPopupEvent returnPopupEvent) { }

The ReturnPopupEvent
object gives you access the RichInputListOfValues
component instance, which represents the af:inputListOfValues component at runtime. From
here you access the Model property
of the component to then get a handle to the CollectionModel.

The CollectionModel
returns an instance of JUCtrlHierBinding
in its getWrappedData
method. Though there is no tree binding definition for the list of values
dialog defined in the PageDef, it exists. Once you have access to this, you can
read the row the user selected in the list of values dialog. See the following

public void returnListener(ReturnPopupEvent returnPopupEvent) {  
  //access UI component instance from return event RichInputListOfValues lovField =

  //The LOVModel gives us access to the Collection Model and //ADF tree binding used to populate the lookup table ListOfValuesModel lovModel =  lovField.getModel(); CollectionModel collectionModel =

  //The collection model wraps an instance of the ADF //FacesCtrlHierBinding, which is casted to JUCtrlHierBinding
  JUCtrlHierBinding treeBinding =
(JUCtrlHierBinding) collectionModel.getWrappedData();

  //the selected rows are defined in a RowKeySet.As the LOV table only
  //supports single selections, there is only one entry in the rks RowKeySet rks = (RowKeySet) returnPopupEvent.getReturnValue();

  //the ADF Faces table row key is a list. The list contains the //oracle.jbo.Key List tableRowKey = (List) rks.iterator().next();
  //get the iterator binding for the LOV lookup table binding
  DCIteratorBinding dciter = treeBinding.getDCIteratorBinding();
  //get the selected row by its JBO key
  Key key = (Key) tableRowKey.get(0); Row rw =  dciter.findRowByKeyString(key.toStringFormat(true));

//work with the row // ...

Join the discussion

Comments ( 3 )
  • Mihai Monday, June 18, 2018
    This doesn't work for me. The rw variable appears to be null.
  • Vaibhav Monday, July 9, 2018
    I am facing same issue. The rw variable appears to be null.
  • Frank Nimphius Monday, July 9, 2018
    Actually this sample is 7 years old, so I would not be surprised if things have changed in the underlying framework since I wrote this post.

    I suggest to post a question to the OTN forum asking for someone in or outside Oracle to take the sample code and run it. If they experience the same, maybe they have a work around.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.