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

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
}

Comments:

Post a Comment:
Comments are closed for this entry.
About

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today