Actually radioOneButton's 'value="#{shoppingCartBean.selectedPaymentMethod}"' got overwritten several times with empty or wrong string. Therefore always shows wrong or no selection in the radio button.
I did following workaround to avoid false setting of 'selectedPaymentMethod' attribute in the Bean class. And made sure 'selectedPaymentMethod' is only get updated by 'valueChanged' method in the Handler class.
Changes made in the valueChanged event of Handler class:
public void valueChanged(ValueChangeEvent event) {
String value = null;
if (event.getSource() instanceof HtmlSelectOneRadio) {
value = ((String) event.getNewValue());
}
if (value != null) {
this.shoppingCartBean.setPaymentMethod(value);
}
}
And modification in the Bean class:
public void setSelectedPaymentMethod(String selectedPaymentMethod) {
// DO NOTHING, Leave this method empty
}
public void setPaymentMethod(String paymentMethod) {
this.selectedPaymentMethod = paymentMethod;
}
Now 'getSelectedPaymentMethod' always returns currently selected radio item, so correct radio item get checked.