Book Image

PrimeFaces Beginner's Guide

By : Siva Prasad Reddy Katamreddy
Book Image

PrimeFaces Beginner's Guide

By: Siva Prasad Reddy Katamreddy

Overview of this book

PrimeFaces is a lightweight UI component framework for JSF based applications. PrimeFaces is very easy to use because it comes as a single JAR file and requires no mandatory XML configuration. It provides more than 100 UI Components and an in-built AJAX support. It also provides theme support for UI components with more than 30 themes out-of-the-box. With PrimeFaces, developers can create rich user interfaces very easily.PrimeFaces Beginners Guide is a practical, hands-on guide that provides you with clear step-by-step exercises,that will help you to learn and explore the features of PrimeFaces.PrimeFaces Beginners Guide starts by showing you how to install PrimeFaces, create sample forms, and perform validations and then looks at various commonly used PrimeFaces utility components. Next, you will look into various basic text input components like form controls, Calendar, AutoComplete, and Rich Text Editor. Then you will learn about advanced UI components such as DataTables, panels, menus,and charts. Throughout the chapters we will be building a sample web application using PrimeFaces progressively that will give you a hands-on experience on using PrimeFaces effectively.You will learn how to create complex layouts using accordion panels, tab views, sophisticated menu navigations, breadcrumbs and much more. You will also learn how to display data using DataTable with pagination, filters, and lazy loading, and how to export data to Excel or PDF features. You will learn how to represent data in various formats like trees, charts, and TagCloud. You will also learn how to build an application supporting multiple themes.With this PrimeFaces Beginner's Guide , you will learn how to use PrimeFaces easily and effectively.
Table of Contents (20 chapters)
PrimeFaces Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
3
Using PrimeFaces Common Utility Components
Index

Preface

PrimeFaces is a leading open source user interface (UI) component library for Java Server Faces (JSF)-based web applications. PrimeFaces provides more than 100 UI components with a rich look and feel and theming support. At the time of writing this book, the latest version of PrimeFaces is 4.0, which works well with JSF 2.x.

PrimeFaces Beginner's Guide will take you through the process of installing, configuring, and using PrimeFaces in your JSF-based web applications. Usage of PrimeFaces components are explained through simple and practical examples with step-by-step instructions. By the end of the book, you will have a hands-on experience on how to use PrimeFaces effectively.

What this book covers

Chapter 1, Introduction to PrimeFaces, introduces PrimeFaces, along with details on how to install and configure it by creating a simple Hello World application. This chapter also provides an overview of various PrimeFaces features, such as AJAX support, Partial Page Rendering (PPR), and explains Poll and Remote Command components, which come in very handy at times.

Chapter 2, Introducing Sample Application TechBuzz, provides an overview of the sample application TechBuzz, which we are going to build incrementally throughout the book, and explains what PrimeFaces components will be used for various requirements. This chapter also provides an overall picture on setting up the development environment with all the required software, such as JDK, IDE, database, and so on.

Chapter 3, Using PrimeFaces Common Utility Components, introduces various commonly used utility components provided by PrimeFaces, such as Growl, Tooltip, BlockUI, NotificationBar, and so on. This chapter also explains new features introduced in PrimeFaces 4.0, such as Fragment, Sticky, Search Expression Framework, and Dialog Framework.

Chapter 4, Introducing PrimeFaces Client Side Validation Framework, covers PrimeFaces Client Side Validations (CSV) Framework in detail, explaining how to configure and enable client-side validations, integrating the CSV framework with the Bean Validation API, and extending the CSV framework to support custom JSF Validators/-Converters and custom Bean Validation Annotations.

Chapter 5, Introducing Text Input Components, covers various input text components such as InputText, InputTextArea, Password, InputMask, Inplace Editor, and Rich Text Editor. This chapter also explains the AutoComplete component in detail, explaining how to use it with POJO support, multiple item selection, and so on.

Chapter 6, Working with Selection Input Components, covers several PrimeFaces selection components, including SelectOneMenu, SelectManyMenu, SelectOneRadio, SelectManyCheckbox, PickList, MultiSelectListbox, and so on.

Chapter 7, Introducing Advanced Input Components, explains how to work with advanced input components, such as Calendar, Rating, Spinner, and Slider. Readers will also learn about uploading and downloading files using FileUpload and FileDownload components. This chapter also explains how to prevent span and bots using CAPTCHA validation.

Chapter 8, Working with Data Components, covers various data components, such as DataList, DataGrid, and explains DataTable features in depth, including pagination, sorting, filtering, row/cell editing, and so on. Readers will also learn about exporting DataTable data to Excel, PDF, and XML using the DataExporter component.

Chapter 9, Introducing Advanced Data Visualization Components, introduces advanced data visualization components, such as Carousel, TagCloud, and Schedule. Readers will also learn about displaying data in a Tree structure using Tree and TreeTable components.

Chapter 10, Working with Layout Components, explains how to create simple and complex layouts using Panel, PanelGrid, AccordionPanel, TabView, and Layout components, and describes various customization options. This chapter also covers creating workflow-style forms using the Wizard component and Portal-like Layouts using the Dashboard component.

Chapter 11, Introducing Navigation Components, explains creating different styles of menus using various navigation components, such as Menu, SlideMenu, TieredMenu, Menubar, MegaMenu, TabMenu, and Breadcrumb.

Chapter 12, Drawing Charts, covers how to visualize data in a graphical format using a variety of chart formats, such as Line, Bar, Pie, and Donut charts. This chapter also introduces how to render charts created by the JFreeChart API.

Chapter 13, Using PrimeFaces Themes, introduces how to use built-in themes provided by PrimeFaces and how to create custom themes using the online ThemeRoller tool. Readers will also learn about how to dynamically change themes using the ThemeSwitcher component. This chapter also gives a brief overview of various PrimeFaces sibling projects, such as PrimeFaces Extensions, PrimeUI, PrimeFaces Mobile, and PrimeFaces Push.

What you need for this book

You will need the following software to follow the examples:

Who this book is for

This book is for you if you would like to learn and use PrimeFaces for your JSF-based applications, and if you are looking for a practical guide with an easy-to–follow, step-by-step approach along with plenty of examples. Prerequisites required for this book are basic JSF and jQuery skills.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can disable AJAX submit by setting attribute ajax="false"."

A block of code is set as follows:

<h:panelGrid columns="2">
  <p:outputLabel value="UserName"/>
  <p:inputText value="#{userController.userName}"/>
  <p:outputLabel value="Password"/>
  <p:password value="#{userController.password}"/>
  <p:commandButton action="#{userController.login}" value="Login" />
</h:panelGrid>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<h:panelGrid columns="2">
  <p:outputLabel value="UserName"/>
  <p:inputText value="#{userController.userName}"/>
  <p:outputLabel value="Password"/>
  <p:password value="#{userController.password}"/>
  <p:commandButton action="#{userController.login}" value="Login" />
</h:panelGrid>

Any command-line input or output is written as follows:

cd /ProgramData/Propeople
rm -r Drush
git clone --branch master http://git.drupal.org/project/drush.git

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "On the Select Destination Location screen, click on Next to accept the default destination."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.