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

Listing data with pickList


The pickList dual list is an input component that is used to transfer data between two different collections with drag-and-drop-based reordering, transition effects, POJO support, client-server callbacks, and more.

How to do it…

The pickList component uses a custom data model, which is an instance of org.primefaces.model DualListModel that contains two lists—one for the source and one for the target. For a pickList implementation that would be used to select countries, the data model could be as follows:

private List<String> countriesSource = new ArrayList<String>();
private List<String> countriesTarget = new ArrayList<String>();

countriesSource.add("England");
countriesSource.add("Germany");
countriesSource.add("Switzerland");
countriesSource.add("Turkey");

private DualListModel<String> countries =
  new DualListModel<String>(countriesSource, countriesTarget);

The definition of the component could be as follows:

<p:pickList...