Book Image

Primefaces Cookbook Second Edition

Book Image

Primefaces Cookbook Second Edition

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

Displaying checkboxes in selectCheckboxMenu


A multiselect input component, SelectCheckboxMenu is based on checkboxes in an overlay menu. Although it is an input component, it is presented to users as a menu so that it makes sense to handle selectCheckboxMenu in this chapter.

In this recipe, we will implement a selectCheckboxMenu component in both simple and advanced forms. In the advanced case, we will learn about the built-in filtering feature. After submitting the selected items, they will be shown in a dialog.

How to do it…

The usage of p:selectCheckboxMenu is the same as the usage of p:selectManyCheckbox. Checkbox items can be attached via several f:selectItem tags or one f:selectItems tag. In the following simple example, we will use f:selectItems to display colors:

<p:selectCheckboxMenu label="Colors"
  value="#{checkboxMenuBean.selectedColors}">
  <f:selectItems value="#{checkboxMenuBean.colors}"/>
</p:selectCheckboxMenu>

The label attribute defines text shown to the...