1

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user3070142
  • 59
  • 1
  • 9

1 Answers1

0

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.

Heather92065
  • 7,333
  • 6
  • 31
  • 39
  • I have put the code in other page and it works well , but when I call it with ui:include in other page,the ajax stop working!! any idea? – user3070142 Mar 09 '16 at 10:50
  • its ok , the probleme is resolved, I have change my bean to @SessionScoped (it was @ViewScoped) – user3070142 Mar 09 '16 at 11:46