Search code examples
buttonprimefacespanel

show panel when button is pressed


I have a button and a panel in primefaces. I want the panel to be visible when I press the button. How can I do it with primefaces?

I have the code

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

but it does not work


Solution

  • You have a typo in your code, the attribute you need is 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"/>
    

    If you don't want to render your panel at all you should consider using the rendered attribute of the component.