Showing posts with label not index. Show all posts
Showing posts with label not index. Show all posts

Sunday, January 6, 2013

Get the current selected value in the backing bean on ValueChangeListener() of SelectOneChoice ADF

 

public void valueChanged(ValueChangeEvent valueChangeEvent) throws Exception{

valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());

DCBindingContainer bindings =

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

DCIteratorBinding iter =

bindings.findIteratorBinding("CountryTRVOIterator");

CountryTRVORowImpl countryRow= (CountryTRVORowImpl) iter.getCurrentRow();

System.out.println(countryRow.getCountryId());

}

or

public void valueChanged(ValueChangeEvent valueChangeEvent){

OperationBinding oper1 = ADFUtils.findOperation("GetHyperLinkEWP");

if (JSFUtils.resolveExpression("#{bindings.ActionRef<attribute_in_bindings>.selectedValue.attributeValues[1]}").toString().equals("Compliant")) {

oper1.getParamsMap().put("BindLabel", "Approval Report");

System.err.println("Approval Report");

} else {

oper1.getParamsMap().put("BindLabel", "Rejection Report");

System.err.println("Rejection Report");

}

oper1.execute();

}

or

if you are trying to get the new value of the select one choice before the value gets updated to model

public void valueChanged(ValueChangeEvent valueChangeEvent) {

this.setValueToEL("#{bindings.Deptno.inputValue}", valueChangeEvent.getNewValue()); //Updates the model

System.out.println("\n******** Selected Value: "+resolveExpression("#{bindings.Deptno.attributeValue}"));

System.out.println("\n******** Display Value: "+resolveExpression("#{bindings.Deptno.selectedValue ne ' ' ? bindings.Deptno.selectedValue.attributeValues[1] : ''}"));

}