Reputation: 105
I want to expand/collapse a fieldset from buttons that are outside and inside of the fieldset, The problem is that not always the effect is the desired one. Some times the fieldset expands and collapses in a blink of an eye, sometimes it remains always open. However if a click in another button wich is not related with the fieldset, it seems that "reset" the state, and buttons starts to work fine for a while, till , for example, when the form validation fails. Here is the whole XHTML. I suspect this is because any AJAX issue
Thanks very much in advance
<p:fieldset id="fs_new_po"
widgetVar="fs_new_po"
legend="#{msg['btn_add_po.manage_po']}"
toggleable="true"
toggleSpeed="500"
collapsed="true">
....
<p:column>
<p:commandButton process="@this"
update=":mng_po:fs_new_po :mng_po:msgs"
value="#{msg['btnCancel']}"
onclick="PF('fs_new_po').toggle();"
actionListener="#{managePO.btnCancelClick}"/>
</p:column>
</p:row>
</p:panelGrid>
</p:fieldset>
...
<p:commandButton process="@this"
update=":mng_po:fs_new_po"
oncomplete="PF('fs_new_po').toggle();"
icon="ui-icon-pencil"
title="edit"
action="#{managePO.btnEditClick}">
<f:setPropertyActionListener value="#{po}" target="#{managePO.selectedPo}"/>
</p:commandButton>
Upvotes: 2
Views: 5440
Reputation: 105
Following the suggestion of Tiny, I update onclick event just the content of the fieldset that could be change.
<p:fieldset id="fs_new_po"
widgetVar="fs_new_po"
legend="#{msg['btn_add_po.manage_po']}"
toggleable="true"
toggleSpeed="500"
collapsed="true">
//ADDED A CONTENT INSIDE THE FIELDSET TO BE UPDATED
<p:panelGrid id="fs_cntnt">
....
<p:column>
//UPDATE JUST THE CONTENT OF THE FIELDSET
<p:commandButton process="@this" update=":mng_po:fs_cntnt :mng_po:msgs" value="# {msg['btnCancel']}" onclick="PF('fs_new_po').toggle();" actionListener="#{managePO.btnCancelClick}" />
</p:column>
</p:row>
</p:panelGrid>
</p:fieldset>
...
//UPDATE JUST THE CONTENT OF THE FIELDSET
<p:commandButton process="@this" update=":mng_po:fs_cntnt" oncomplete="PF('fs_new_po').toggle();" icon="ui-icon-pencil" title="edit" action="#{managePO.btnEditClick}" >
<f:setPropertyActionListener value="#{po}" target="#{managePO.selectedPo}" />
</p:commandButton>
Thank you Tiny!
Upvotes: 2