Reputation: 31
I have a panel which is collapsed when first opening the page and should get updated with an p:ajax attached to a selectOneButton
<p:selectOneButton required="true"
value="#{bean.jobProfile.salary.subjectToDisclosure}"
id="salarySubjectToDisclosure">
<f:selectItem itemValue="#{true}" itemLabel="#{msg['yes']}" />
<f:selectItem itemValue="#{false}" itemLabel="#{msg['no']}" />
<p:ajax
listener="#{bean.changeSubjectToDisclosure()}"
update="@(.paymentDetailsSliderHeaderUpdateable) grossPaymentWrapper" />
</p:selectOneButton>
So. There are 2 options. Yes and No. On yes the panel with the id grossPaymentWrapper should get displayed and on no collapsed.
The panel:
<p:panel id="grossPaymentWrapper">
#{!bean.jobProfile.salary.subjectToDisclosure}
<p:panel toggleable="true"
collapsed="#{!bean.jobProfile.salary.subjectToDisclosure}">
The line #{!bean.jobProfile.salary.subjectToDisclosure}
always gets updated displaying true or false when selecting a different button, but the panel is not visible for both options.
Help is appreciated
Thanks.
Upvotes: 0
Views: 665
Reputation: 644
Have you tried setting the attribute toggleable="true"
of the inner p:panel
component?
The documentation of the p:panel component describes the collapsed attribute as
"Renders a toggleable panel as collapsed. Default is false."
Link to documentation: http://www.primefaces.org/docs/vdl/6.0/core/primefaces-p/panel.html
Upvotes: 1
Reputation: 1887
You can do this using JavaScript, Primfaces p:panel have a JavaScript function called toggle()
, you can call be by adding a widgetVar
to your p:panel
, the call the toggle
function on that component.
<p:panel id="..." widgetVar="panel">
...
</p:panel>
and then use : PF('panel').toggle()
Upvotes: 0