【问题标题】:Primefaces Panels don't update collapsed status after a dialog was dismissed关闭对话框后 Primefaces 面板不会更新折叠状态
【发布时间】:2015-06-15 14:25:40
【问题描述】:

我看到 Primefaces (4.0) 的奇怪行为与面板相关,面板的折叠属性绑定到支持 bean 中的属性。更新状态可以正常工作,因此当支持 bean 的值发生更改时,面板会正确折叠/展开。 问题是:我有一些 p:Dialogs 可以打开以输入一些附加/可选信息。关闭对话框后,更改值时面板无法展开/折叠。奇怪的是,绑定到同一属性的其他属性会像以前一样更新。

示例
两个面板的 XHTML,其折叠属性绑定到一个属性。请注意,复选框的 disabled-attribute 绑定到相同的属性,并且在对话框关闭后仍然会更新。

<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 在同一页面上的其他地方打开一个对话框:

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

对话框是这样配置的:

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

支持 bean 是一个简单的 bean,具有明显可以工作的属性和 getter/setter。我的实现有问题吗?任何想法如何解决这个问题? 提前致谢!

【问题讨论】:

    标签: jsf jsf-2 primefaces


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-09-20
      • 2016-08-30
      • 1970-01-01
      • 2014-12-04
      • 2016-10-15
      • 2013-08-04
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多