I am facing an issue with h:selectOneRadio\'s valueChangeListener=\"#{user.loadYesNo}\" (I use Mojarra 2-0-8 on Tomcat-7) . If I remove both the panelGrid enclosing the \'h
You need to put the bean in the view scope in order to retain the underlying condition of the rendered
attribute for the subsequent requests.
@ManagedBean
@ViewScoped
public class User {
// ...
}
Unrelated to the concrete problem, the valueChangeListener
is intended to be used whenever you want to have a hook on the server side value change event which allows you to have both the old value and the new value at your hands. For example, to log an event. It's not intended to perform business actions based on the change. For that you should be using the listener
attribute of <f:ajax>
instead.
So, replace
<h:selectOneRadio id="yesNoRadio" value ="#{user.yesNoRadio}" valueChangeListener="#{user.loadYesNo}">
<f:selectItem itemValue="1" itemLabel="YES"></f:selectItem>
<f:selectItem itemValue="0" itemLabel="NO"></f:selectItem>
<f:ajax event="change" execute="@form" render="userDetailsGrid "></f:ajax>
</h:selectOneRadio>
with
<h:selectOneRadio id="yesNoRadio" value ="#{user.yesNoRadio}">
<f:selectItem itemValue="1" itemLabel="YES"></f:selectItem>
<f:selectItem itemValue="0" itemLabel="NO"></f:selectItem>
<f:ajax execute="@form" listener="#{user.loadYesNo}" render="userDetailsGrid"></f:ajax>
</h:selectOneRadio>
and remove the ValueChangeEvent
attribute from the method.