关闭时如何设置xhtml面板的标题

How to set title of a xhtml panel when it is closed

我使用这个代码:

<p:panel header="Advanced User Data" toggleable="true" toggleOrientation="horizontal" collapsed="true">
    some other stuff...
</p:panel>

是否有一个属性可以在面板关闭时设置标题,如下所示: example

据我所知,没有这样的属性。您可以将 collapsed 属性的值绑定到托管 bean,并在 toggle 事件上添加一个 AJAX 侦听器:

<p:panel header="Advanced User Data" toggleable="true"
    toggleOrientation="horizontal" collapsed="#{myBean.booleanVal}" style="display: inline-block;">
    <p:ajax event="toggle" process="@this" update="pnlAlternativeTitle" />
</p:panel>
<h:panelGroup id="pnlAlternativeTitle">
    <h:outputText rendered="#{myBean.booleanVal}"
        value="Alternative title" />
</h:panelGroup>