I would like to display a <p:panel>
when selecting an item of <p:selectOneRadio>
. It works when selecting for the first time, but after the ajax call it stops working.
<p:selectOneRadio id="console" value="#{myBean.membre}">
<f:selectItem itemLabel="a" itemValue="false" />
<f:selectItem itemLabel="b" itemValue="true" />
<p:ajax update="panel2,panel1" />
</p:selectOneRadio>
<p:panel id="panel1" visible="#{myBean.membre == false}"
closable="true" toggleable="true">
<ui:include src="a.xhtml" />
</p:panel>
<p:panel id="panel2" visible="#{myBean.membre == true}"
closable="true" toggleable="true">
<ui:include src="b.xhtml" />
</p:panel>
On PrimeFaces 4.0, I had to remove the closable attributes from the panels before I could toggle the visibility. I also added a form which is always required when working with form fields.
Here is my working solution:
<h:form id="testForm">
<p:selectOneRadio id="console" value="#{myBean.membre}">
<f:selectItem itemLabel="a" itemValue="false" />
<f:selectItem itemLabel="b" itemValue="true" />
<p:ajax update="panel2,panel1" />
</p:selectOneRadio>
<p:panel id="panel1" visible="#{not myBean.membre}" toggleable="true">
test 111
</p:panel>
<p:panel id="panel2" visible="#myBean.membre}" toggleable="true">
test 222
</p:panel>
</h:form>
Why the closable attribute conflicts with the visible attribute I don 't know. It is possible a bug or unplanned for combination.