有条件地基于selectOneMenu值渲染另一个组件

时间:2016-10-13 09:31:55

标签: jsf selectonemenu conditional-rendering

这是我的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"时才会填充这两个复选框?

0 个答案:

没有答案
相关问题