选择后,SelectOneRadio不会隐藏panelGrid

时间:2015-07-21 14:20:44

标签: primefaces selectoneradio panelgrid

我正在使用primefaces selectoneradio控件,它会在选择后显示或隐藏panelgrid。但是不知道为什么当selectl allTeachers无线电时它无法隐藏这个panelgrid

public boolean getVisibleTeacherList() {
    if (this.selectedAllTeachersFlag == "AllTeachers")
        return false;
    else 
        return true;
}
<p:panelGrid columns="2">
    <p:selectOneRadio id="console" value="#{chkTeacherList.selectedAllTeachersFlag}">
        <f:selectItem itemLabel="All teachers" itemValue="AllTeachers" />
        <f:selectItem itemLabel="Selected teachers" itemValue="SelectedTeachers" />
        <p:ajax update="panelGrid1a1" />
    </p:selectOneRadio>
</p:panelGrid>
<p:panelGrid id="panelGrid1a1" rendered="#{chkTeacherList.getVisibleTeacherList()}" columns="1" styleClass="ui-edb-noneborder-grid">
    <p:separator style="border: 1px solid #8c4eea;" />
    <p:panelGrid id="panelGrid1"  columns="3" styleClass="ui-edb-noneborder-grid">
        <p:selectManyCheckbox layout="grid" id="gridTeacherName"  value="#{chkTeacherList.selectedValue}" 
                             columns="3">
            <f:selectItems value="#{chkTeacherList.filterTeacherNameList}" var="teacher" itemLabel="#{teacher.teacherEngName}" itemValue="#{teacher.timRefNo}" />
        </p:selectManyCheckbox>
    </p:panelGrid>
    <p:separator style="border: 1px solid #8c4eea;" />
</p:panelGrid>

3 个答案:

答案 0 :(得分:0)

问题可能在于您的布尔getter getVisibleTeacherListisVisibleTeacherList属性应为visibleTeacherList

更多的是,我认为这个单独的财产不是必需的。您可以使用以下方法处理panelGrid的渲染:

rendered="#{chkTeacherList.selectedAllTeachersFlag eq 'AllTeachers'}"

答案 1 :(得分:0)

要添加或删除组件(当它更改其NTriplesFormatter formatter = new NTriplesFormatter(); foreach (Triple t in Space.Triples) { Console.WriteLine(t.ToString(formatter)); } 值时),您需要更新组件本身,而不是其祖先组件之一。

例如,假设您的rendered位于panelGrid1a1内。

parentPanel

然后,您的<p:outputPanel id="parentPanel"> <p:panelGrid id="panelGrid1a1" rendered="#{chkTeacherList.getVisibleTeacherList()}" ... ... </p:outputPanel> p:selectOneRadio应更新p:ajax

parentPanel

答案 2 :(得分:0)

快速修复尝试替换它:

this.selectedAllTeachersFlag == "AllTeachers"

this.selectedAllTeachersFlag.equals("AllTeachers")

<强>差分

  • “==”是参考比较,即两个对象指向相同的存储位置。其中
  • “equals()”计算对象中值的比较。