这是我的h:selectOneMenu
部分,下拉单击在 UI 上显示 3 个值(A、B 和 C)(我们在包含 A、B、C 的 bean 中有 domainList 方法):
<h:form id="MainForm">
<h:panelGrid columns="1">
<h:selectOneMenu id="domainList" value="#{bean.domain}" listener="#{bean.changeDomainValue}">
<f:selectItem itemLabel="#{msg.abc }"/>
<f:selectItems value="#{bean.dMap.entrySet()}"
var="entry" itemLabel="#{entry.key}" itemValue="#{entry.value}"/>
<f:ajax event="change" render="??????"/>
</h:selectOneMenu>
</h:panelGrid>
这是我关心的问题,如果我Value="C"
从下拉列表中选择,我需要在现有表单中添加两个复选框(一个额外的字段):
<h:panelGrid columns="2">
<h:outputLabel value="#{msg.box1}"></h:outputLabel>
<h:selectBooleanCheckbox value="#{bean.chkBox1}"></h:selectBooleanCheckbox>
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputLabel value="#{msg.box2} :"></h:outputLabel>
<h:selectBooleanCheckbox value="#{bean.chkBox2}"></h:selectBooleanCheckbox>
</h:panelGrid>
</h:form>
这是我的Bean.java
:
private void changeDomainValue(ValueChangeEvent e) {
if (e.getNewValue() == "C") {
this.chkBox1 = "true";
this.chkBox2 = "true";
} else
this.chkBox1 = "false";
this.chkBox2 = "false";
//return false;
}
问题:要在渲染属性上添加什么,以便这两个复选框只有在我选择时才会填充domainList= "c"
?