按下按钮时显示面板

时间:2012-10-15 19:24:32

标签: button primefaces panel

我有一个按钮和一个面板。我想按下按钮时可以看到面板。我怎样才能使用primefaces?

我有代码

        <p:commandButton value="Search" ajax="false"
        actionListener="#{myBean.searchPatients}" onclick="panelwv.show();">
    </p:commandButton>
    <p:panel widgetvar="panelwv" visible="false" closable="true" toggleable="true" >

但它不起作用

2 个答案:

答案 0 :(得分:8)

您的代码中有拼写错误,您需要的属性为widgetVar

<p:commandButton value="Search" ajax="false"
    actionListener="#{myBean.searchPatients}" onclick="panelwv.show();">
</p:commandButton>
<p:panel widgetVar="panelwv" visible="false" closable="true" toggleable="true"/>

如果您根本不想渲染面板,则应考虑使用该组件的rendered属性。

答案 1 :(得分:0)

您可以为此使用对话框。您还可以检查

https://www.primefaces.org/showcase/ui/overlay/dialog/basic.xhtml

<p:commandButton value="Search" ajax="false"
actionListener="#{myBean.searchPatients}" oncomplete="PF('dlg1').show();">
</p:commandButton>
<p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
<p:panel  visible="false" closable="true" toggleable="true"/>
</p:dialog>