Reputation: 217
I am using primefaces selectoneradio
control which will show or hide the panelgrid
after selection. But does not know why it cannot hide this panelgrid
when selectl allTeachers radio.
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>
Upvotes: 0
Views: 444
Reputation: 1976
A quick fix try replacing this:
this.selectedAllTeachersFlag == "AllTeachers"
with
this.selectedAllTeachersFlag.equals("AllTeachers")
Difference
Upvotes: 0
Reputation: 4206
To add or remove component (when it changes its rendered
value) you need to update not the component itself, but one of its ancestor components.
E.g., say your panelGrid1a1
is located inside parentPanel
.
<p:outputPanel id="parentPanel">
<p:panelGrid id="panelGrid1a1" rendered="#{chkTeacherList.getVisibleTeacherList()}" ...
...
</p:outputPanel>
Then your p:selectOneRadio
's p:ajax
should update parentPanel
.
<p:selectOneRadio id="console" ...
...
<p:ajax update="parentPanel" />
</p:selectOneRadio>
Upvotes: 0
Reputation: 4730
The issue can be with your boolean getter getVisibleTeacherList
. It should be isVisibleTeacherList
for visibleTeacherList
property.
More-ever, I think this separate property is not required. You can handle rendering of panelGrid using:
rendered="#{chkTeacherList.selectedAllTeachersFlag eq 'AllTeachers'}"
Upvotes: 0