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 notification messages

Let us see how to create a simple notification bar to display a message using JavaScript show() and hide() methods.

  1. Create a NotificationBar component to display notification messages and two buttons to show and hide the notification bar widget:
    <p:notificationBar id="bar" widgetVar="notifBar" style="height:20px; background-color: #8B0000;">
      <h:outputText value="There are New Unread Emails in your MailBox." style="color:#FFF;font-size:20px;"/>
    </p:notificationBar>
    <h:form>
      <p:commandButton value="Show" onclick="notifBar.show()"/>
      <p:commandButton value="Hide" onclick="notifBar.hide()"/>
    </h:form>

What just happened?

We have created a notification bar widget using a <p:notificationBar> component. When ...

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