I was taking a look at this question and tried to find an answer, I was trying, I made this code
JSF :
<h:form id="form">
<h:inputText id="text1" rendered="#{managedBean1.isRendered}"/>
<h:outputLabel id="label1" rendered="#{!managedBean1.isRendered}" value="No"/>
<h:selectOneRadio value="#{managedBean1.option}" >
<f:selectItem itemValue="Yes" itemLabel="Yes" />
<f:selectItem itemValue="No" itemLabel="No" />
<f:ajax event="click" execute="@form" render="label1 text1" />
</h:selectOneRadio>
</h:form>
The bean :
@ManagedBean
@ViewScoped
public class ManagedBean1 implements Serializable {
private boolean isRendered = false;
private String option ;
public void renderingMethod() {
if(option.compareTo("Yes")==0) isRendered = true ;
if(option.compareTo("No")==0) isRendered = false ;
}
public String getOption() {
return option;
}
public void setOption(String option) {
this.option = option;
}
public boolean isIsRendered() {
return isRendered;
}
public void setIsRendered(boolean isRendered) {
this.isRendered = isRendered;
}
/**
* Creates a new instance of ManagedBean
*/
public ManagedBean1() {
}
}
Problem is it doesn't fire the ajax in the <h:selectOneRadio>
, on the other hand it works just fine with a submit <h:commandButton>
, why is that ? What am I missing ?