X

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

  • ADFm
    December 14, 2010

Reading the selected value of an ADF bound Select List in Java

Frank Nimphius
Master Principal Product Manager


Model driven and dynamic select lists are bound to the JUCtrlListBinding in
the associated binding container. To read the user selected list value in a
managed bean, the list component AutoSubmit
property must be set to "true". The ValueCangeListener property then references a managed bean method
to read the selected value.

At design time, the select list is defined in the PageDef
file of the page or page fragment containing the list component. The name of
the list binding is referenced in the managed bean method shown below.

The managed bean method shown below accesses

  • the selected list index
  • the selected list value
  • the selected list row

public
void onEmployeesListChange(ValueChangeEvent valueChangeEvent) {

  BindingContext bctx =
BindingContext.getCurrent();

  BindingContainer bindings =
bctx.getCurrentBindingsEntry();

  JUCtrlListBinding list =

             (JUCtrlListBinding) bindings.get("DepartmentId");     

  //get the selected Row. This allows you
to access row attributes
  //that are not displayed in the list

  Row selectedRow =
(Row)list.getSelectedValue();

  //get
selected list value. This is the value used to update the

  //Select List value attribute

  Number selectedValue = (Number)
list.getAttributeValue();

  //get
the selected list index

  Integer
selectedIndx = (Integer) valueChangeEvent.getNewValue();       

  // ...
do more work here

}

Be the first to comment

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