Primefaces Panels don't update collapsed status after a dialog was dismissed

时间:2015-06-15 14:25:41

标签: jsf jsf-2 primefaces

I'm seeing a strange behaviour with Primefaces (4.0) related to Panels whose collapsed-attributes are bound to a property in a backing bean. Updating the state works fine so the panel collapses/expands correctly when the value of the backing bean changes. The problem is: I have some p:Dialogs that can be opened to enter some additional/optional information. After closing the dialog, the panel fails to expand/collapse when changing the value. Strangely, other attributes bound to the same property get updated like before.

Example:
XHTML of two panels whose collapsed Attribute is bound to a property. Note that the disabled-attribute of the checkboxes are bound to the same property and still get updated after the dialog is closed.

<p:panel id="panel1" style="width:80%;" toggleable="true" collapsed="#{!bean.panel1.enabled}" widgetVar="panel1Var">
        <f:facet name="header">
        <p:outputLabel value="Panel1"/>
        <p:selectBooleanCheckbox id="p1_enabled" style="margin-left:20px;" disabled="#{bean.panel2.enabled}" value="#{bean.panel1.enabled}">
        <f:ajax  render="panel1 panel2" />
        </p:selectBooleanCheckbox>
</f:facet>  
    <p:panelGrid columns="2" style="width:100%;" columnClasses="input-col1,input-col2">
    <!-- omitted -->
    </p:panelGrid>
</p:panel>

<p:panel id="panel2" style="width:80%;" toggleable="true" collapsed="#{!bean.panel2.enabled}" widgetVar="panel2Var">
        <f:facet name="header">
        <p:outputLabel value="Panel2"/>
        <p:selectBooleanCheckbox id="p2_enabled" style="margin-left:20px;" disabled="#{bean.panel1.enabled}" value="#{bean.panel2.enabled}">
        <f:ajax  render="panel1 panel2" />

        </p:selectBooleanCheckbox>
</f:facet>  
    <p:panelGrid columns="2" style="width:100%;" columnClasses="input-col1,input-col2">
    <!-- omitted -->
    </p:panelGrid>
</p:panel>

XHTML somewhere else on the same page which opens a dialog:

<p:commandLink id="contactbutton" onclick="PF('contactextended').show();">
        <h:outputText value="Extended" />
    </p:commandLink>

The dialog is configured like this:

<p:dialog widgetVar="contactextended" modal="true" width="600px" height="500px" showEffect="fade" hideEffect="fade" resizable="false" draggable="false">

The backing bean is a straightforward bean with properties and getters/setter which obviously work. Is there a problem in my implementation? Any ideas how to work around this issue? Thanks in advance!

1 个答案:

答案 0 :(得分:1)

我自己解决了这个问题。解决方案似乎是将process="@this"添加到commandLink。我仍然不确定底层问题是什么,但至少它不再被触发。