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 dataList


A collection of data in a list layout is presented by dataList with several display types and features, such as AJAX pagination.

How to do it…

A basic definition of a data list with a header facet for listing the names of countries starting with the letter "A" would be as follows:

<p:dataList id="simple" value="#{dataListBean.countriesShort}"
  var="country" itemType="disc">
  <f:facet name="header">
    Countries starting with 'A'
  </f:facet>
  <h:outputText value="#{country}" />
</p:dataList>

By default, the dataList component renders an unordered list, which corresponds to the <ul> HTML tag. The visual output is given here:

The bullet type can be customized with the itemType attribute, which has the default value disc. For an unordered list, the other possible values are circle and square.

When type is set to ordered, dataList renders an ordered list, which corresponds to the <ol> HTML tag. The visual output is given here...