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 – using the SelectBooleanButton component

Let us see how to save user preferences on subscribing to weekly e-mail notifications using the <p:selectBooleanButton> component, by performing the following steps:

  1. Create a User Preferences form:
    <h:form> <p:panel header="User Preferences" style="width: 400px; margin: 0 auto;"> <p:messages autoUpdate="true"/> <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"> <h:outputText value="Subscribe to Email Notifications: " /> <p:selectBooleanButton value="#{selectionController.subscribeToEmailNotif}" onLabel="Yes" offLabel="No" onIcon="ui-icon-check" offIcon="ui-icon-close"> <p:ajax update="display" listener="#{selectionController.handleEmailSubscription}"/> </p:selectBooleanButton> ...

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