按下按钮时显示面板

lou*_*bas 6 panel button primefaces

我有一个按钮和一个面板.我想按下按钮时可以看到面板.我怎样才能使用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" >
Run Code Online (Sandbox Code Playgroud)

但它不起作用

Ako*_*s K 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"/>
Run Code Online (Sandbox Code Playgroud)

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