Monday, June 1, 2009

usefull code to get new value of select one Radio by ValueChangeListener Bean

Hi , have tried to get selected new value of ADF Select one radio item and get it by below code.

selectOneRadio JSF code
Note: Make sure that autoSubmit = "true"
<af:selectOneRadio value="#{bindings.RtNo.inputValue}"
required="#{bindings.RtNo.hints.mandatory}"
shortDesc="#{bindings.RtNo.hints.tooltip}"
autoSubmit="true"
valueChangeListener="#{Bn_global.Sone}">
<f:selectItems value="#{bindings.RtNo.items}"/>
</af:selectOneRadio>


Backing Bean

public void Sone(ValueChangeEvent valueChangeEvent) {

if(valueChangeEvent.getNewValue()!=null)
{

//get NewValue Index and parse to integrer
int selectIndex = Integer.parseInt(valueChangeEvent.getNewValue().toString()) ;

DCBindingContainer dcBindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

// Get a attribute value of the current row of iterator
DCIteratorBinding iterBind =
(DCIteratorBinding)dcBindings.get("VOUserBranchList1Iterator"); //VOUserBranchList1Iterator is iteration name what I used

//get row of current index
Row selectedRow =iterBind.getRowAtRangeIndex(selectIndex);

if (selectedRow != null)
{
//get Row value
Object selectValue = (String)selectedRow.getAttribute("RtNo"); //RtNo is AttributeName what I used
}
}
}

Thanks to Jdeveloper Forum .


No comments:

Post a Comment