我正在看这个问题并试图找到答案,我正在尝试,我制作了这段代码
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>
豆子:
@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() {
}
}
问题是它不会触发 ajax,<h:selectOneRadio>
另一方面它在提交时工作得很好<h:commandButton>
,这是为什么呢?我错过了什么?