Book Image

PrimeFaces Cookbook

Book Image

PrimeFaces Cookbook

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Discovering selectBooleanCheckbox and selectManyCheckbox


To provide skinning, selectBooleanCheckbox and selectManyCheckbox extend the default JSF components <h:selectBooleanCheckbox> and <h:selectManyCheckbox>, respectively.

How to do it…

Basic definitions for selectBooleanCheckbox and selectManyCheckbox would be as follows:

<p:selectBooleanCheckbox
  value="#{selectCheckboxBean.selectedValue}" />

<p:selectManyCheckbox 
  value="#{selectCheckboxBean.selectedCountries}">
  <f:selectItem itemLabel="Turkey" itemValue="Turkey" />
  <f:selectItem itemLabel="Germany" itemValue="Germany" />
  <f:selectItem itemLabel="Switzerland" itemValue="Switzerland" />
</p:selectManyCheckbox>

Adding labels to the checkbox is easy with the itemLabel attribute. The itemLabel attribute displays a label next to the checkbox:

<p:selectBooleanCheckbox 
  value="#{selectCheckboxBean.selectedValue}"
  itemLabel="#{msg['selectBooleanCheckbox.label']}" />

The text that...