Search This Blog

Select one Choice ADF - ValueChange Event ( Selected Values From Drop down )

   
 Select one Choice ADF - ValueChange Event ( Selected Values From Drop down ) 


Most of the developers face issue when using Select One Choice. Index display rather than selected Value.  





Jspx Code :
 

  <af:selectOneChoice value="#{bindings.DepartmentId.inputValue}"
                            label="#{bindings.DepartmentId.label}"
                            required="#{bindings.DepartmentId.hints.mandatory}"
                            shortDesc="#{bindings.DepartmentId.hints.tooltip}"
                            id="soc1" autoSubmit="true"
                            valueChangeListener="#{pageFlowScope.ValueMbean.ValueChnageMethod}">
          <f:selectItems value="#{bindings.DepartmentId.items}" id="si1"/>
        </af:selectOneChoice>


 Java Code :

 public void ValueChnageMethod(ValueChangeEvent valueChangeEvent) {
  

         System.out.println(" Selected Index ::: " + valueChangeEvent.getNewValue());

         BindingContainer bindings =BindingContext.getCurrent().getCurrentBindingsEntry();
         JUCtrlListBinding listBinding =(JUCtrlListBinding)bindings.get("DepartmentId");
         listBinding.setSelectedIndex(Integer.parseInt(valueChangeEvent.getNewValue().toString()));
         Row selectedValue = (Row) listBinding.getSelectedValue();

        System.out.println(" Selected Value ::: " +selectedValue.getAttribute("DepartmentId"));
    }



OutPut :


 Selected Index::: 11
 Selected Value ::: 100

 Selected Index::: 17
  Selected Value ::: 30

 Selected Index::: 23
 Selected Value :::  50

No comments:

Post a Comment