O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – displaying a dialog

Let us see how to create a basic Dialog component and show/hide based on button click events by performing the following steps:

  1. Create a form with a Dialog component and two buttons to show and hide the dialog using the following code:
    <h:form>
      <p:commandButton value="ShowDialog" onclick="dlg1.show();" type="button" />
      <p:commandButton value="HideDialog" onclick="dlg1.hide();" type="button" />
      <p:dialog id="simpleDialog" header="Simple Dialog" widgetVar="dlg1" width="300" height="50">
        <h:outputText value="PrimeFaces Simple Dialog" />
      </p:dialog>
    </h:form>

What just happened?

We have created a Dialog component using <p:dialog> and used two <p:commandButton> components to perform show and hide actions on the dialog ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required