JSF 2.0 Cookbook

JSF 2.0 Cookbook
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters


  • Discover JSF 2.0 features through complete examples
  • Put in action important JSF frameworks, such as Apache MyFaces Core, Trinidad, Tomahawk, RichFaces Core, Sandbox and so on
  • Develop JSF projects under NetBeans/Glassfish v3 Prelude and Eclipse/JBoss AS
  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

Book Details

Language : English
Paperback : 396 pages [ 235mm x 191mm ]
Release Date : June 2010
ISBN : 1847199526
ISBN 13 : 9781847199522
Author(s) : Anghel Leonard
Topics and Technologies : All Books, Networking and Servers, Cookbooks, Java, Open Source

Table of Contents

Chapter 1: Using Standard and Custom Converters in JSF
Chapter 2: Using Standard and Custom Validators in JSF
Chapter 3: File Management
Chapter 4: Security
Chapter 5: Custom Components
Chapter 6: AJAX in JSF
Chapter 7: Internationalization and Localization
Chapter 8: JSF, Images, CSS, and JS
Chapter 9: JSF—Managing and Testing
Chapter 10: Facelets
Chapter 11: JSF 2.0 Features
Chapter 12: Mixing JSF with Other Technologies
Appendix: Configuring JSF-related Technologies
  • Chapter 1: Using Standard and Custom Converters in JSF
    • Introduction
    • Working with implicit and explicit conversions
    • Standard converters for numbers
    • Standard converters for date and time
    • Converters and NULL values
    • Creating and using a custom converter
    • Using custom converters for h:selectOneMenu
    • Binding converters to backing bean properties
    • RichFaces and standard converters
    • RichFaces and custom converters
    • Instance variables in converters
    • Client-side converters with MyFaces Trinidad
  • Chapter 2: Using Standard and Custom Validators in JSF
    • Introduction
    • Using a standard validator
    • Customizing error messages for validators
    • Creating a custom validator
    • Binding validators to backing bean properties
    • Validating forms with RichFaces rich:beanValidator
    • Validating forms with RichFaces rich:ajaxValidator
    • Apache MyFaces Commons validators
    • Bean validation with f:validateBean
    • Enforcing a value's presence with f:validateRequired
    • Using regular expressions with f:validateRegex
  • Chapter 3: File Management
    • Introduction
    • Downloading files using Mojarra Scales
    • Multi-file upload using Mojarra Scales
    • File upload with Apache MyFaces Tomahawk
    • AJAX multi-file upload with RichFaces
    • Downloading with PrimeFaces 2.0
    • PPR multi-file upload with PrimeFaces 2.0
    • Extracting data from an uploaded CSV file
    • Exporting data to Excel, PDF, CVS, and XML
  • Chapter 4: Security
    • Introduction
    • Working with the JSF Security project
    • Using the JSF Security project without JAAS Roles
    • Using secured managed beans with JSF Security
    • Using Acegi/Spring security in JSF applications
  • Chapter 5: Custom Components
    • Introduction
    • Building a "HelloWorld" JSF custom component
    • Renderers/validators for custom components
    • Adding AJAX support to JSF custom components
    • Using Proxy Id library for dynamic IDs
    • Using JSF ID Generator
    • Accessing resources from custom components
    • Custom components with Archetypes for Maven
    • RichFaces CDK and custom components
    • Composite custom components with zero Java
    • Creating a login composite component in JSF 2.0
    • Building a spinner composite component in JSF 2.0
    • Mixing JSF and Dojo widget for custom components
  • Chapter 6: AJAX in JSF
    • Introduction
    • A first JSF 2.0-AJAX example
    • Using the f:ajax tag
    • Installing and using Dynamic Faces in NetBeans 6.8
    • Using the inputSuggestAjax component
    • ajax4jsf—more than 100 AJAX components
    • Writing reusable AJAX components in JSF 2.0
    • PrimeFaces, CommandLink, and CommandButton
  • Chapter 7: Internationalization and Localization
    • Introduction
    • Loading message resource bundles in JSF
    • Using locales and message resource bundles
    • Message resource bundles without f:loadBundle
    • Working with parameterized messages
    • Accessing message resource keys from a class
    • Providing a theme to a Visual Web JSF Project
    • Displaying Arabic, Chinese, Russian, and so on
    • Selecting a time zone in JSF 2.0
  • Chapter 8: JSF, Images, CSS, and JS
    • Introduction
    • Injecting CSS in JSF
    • JSF, CSS, and tables
    • JSF and dynamic CSS
    • Integrating JavaScript and JSF
    • Getting a JSF inputText value from JavaScript
    • Working with JSF hidden fields from JavaScript
    • Passing parameters from JS to JSF (client to server)
    • Passing parameters from JSF to JS (server to client)
    • Opening a pop-up window using JSF and JS
    • Passing parameters with HTTP GET within the URL
    • Communication between parent pop-up windows
    • Populating a JS load function with JSF values
    • Dynamic images with PrimeFaces
    • Cropping images with PrimeFaces
    • Working with rss4jsf project
    • Using resource handlers
  • Chapter 9: JSF—Managing and Testing
    • Introduction
    • Managing JSF with Faces Console
    • Testing JSF applications with JSFUnit
    • JSFUnit and Ant
    • JSFUnit API
    • A JSF and JMeter issue
    • Working with JSF Chart Creator
  • Chapter 10: Facelets
    • Introduction
    • Installing Facelets under JSF 1.2 (or JSF 1.1)
    • Facelets aliasing components
    • Facelets templating
    • Creating composition components in JSF 2.0
    • Passing sub-elements to composition components
    • Passing actions to composition components
  • Chapter 11: JSF 2.0 Features
    • Introduction
    • JSF 2.0 annotations
    • The JSF 2.0 exception handling mechanism
    • Bookmarking JSF pages with PrettyFaces
    • JSF declarative event handling
    • URLs based on specified navigation outcome
    • JSF view parameters
    • JSF 2 and navigation cases
  • Appendix: Configuring JSF-related Technologies
    • Apache MyFaces Trinidad (supports JSF 2.0)
    • RichFaces (supports JSF 2.0)
    • Apache MyFaces Tomahawk (supports JSF 1.2)
    • Apache MyFaces Tomahawk Sandbox (supports JSF 1.2)
    • Mojarra Scales (supports JSF 1.2)
    • j4j (supports JSF 2.0)
    • rss4jsf (supports JSF 2.0)

Anghel Leonard

Anghel Leonard is a senior Java developer with more than 13 years of experience in Java SE, Java EE, and related frameworks. He has written and published more than 50 articles about Java technologies and more than 500 tips and tricks for many websites that are dedicated to programming. In addition, he has written the following books:

  • Tehnologii XML XML în Java, Albastra
  • Jboss Tools 3 Developer's Guide, Packt Publishing
  • JSF 2.0 Cookbook, Packt Publishing
  • JSF 2.0 Cookbook: LITE, Packt Publishing
  • Pro Java 7 NIO.2, Apress
  • Pro Hibernate and MongoDB, Apress

Currently, Anghel is developing web applications using the latest Java technologies on the market (EJB 3.0, CDI, Spring, JSF, Struts, Hibernate, and so on). Over the past two years, he's focused on developing rich Internet applications for geographic information systems.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 1 submitted: last submission 11 Nov 2013

On page 13, instead of currenySymbol, the Attribute name should be currencySymbol.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

JSF 2.0 Cookbook +    Microsoft Silverlight 5 Data and Services Cookbook =
50% Off
the second eBook
Price for both: €35.15

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book


  • Explore all the new features of JSF 2.0 that has numerous advantages over JSF 1.2
  • Work with standard and custom JSF converters and validators
  • Learn to upload and download with JSF, RichFaces and MyFaces
  • Work with resources such as CSS, JavaScript and images
  • Develop sophisticated applications using standard and custom components
  • Explore AJAX in JSF and related frameworks
  • Enhance your applications with internationalization and localization
  • Exploit all of the security tasks in JSF and perform thorough testing of your applications
  • Get to grips with JSFUnit, JMeter and JXIsight
  • Integrate JSF with JSTL, Spring and Hibernate

In Detail

JavaServer Faces is a Java-based Web application framework intended to simplify development of user interfaces for Java EE applications. You may already be aware of the laborious search through reference guides and documentation to develop your JSF applications. With the JSF Cookbook, you can find solutions to the most common JSF problems in a quick and easy way.

This book will cover all the important aspects involved in developing JSF applications. It provides clear instructions for getting the most out of JSF and offers many exercises to build impressive desktop-style interfaces for your web applications. Develop JSF applications starting with simple recipes and gradually moving on to complex recipes.

We discuss all of the fundamental aspects of JSF applications. Once you locate your desired topic, you can try to find a recipe that corresponds to your problem.

We start off with the simple concepts of Converters, validators and file management. We then work our way with various resources such as CSS, JavaScript, and images to improve your web applications. You will learn to build simple and complex custom components to suit your needs. Next, you get to exploit AJAX as well as implement internationalization and localization for your JSF applications. We then look into ensuring security for your applications and perform testing of your applications. You also get to learn all about Facelets and explore the newest JSF 2.0 features. Finally you get learn a few integrations such as JSTL with JSF, Spring with JSF, and Hibernate with JSF. All these concepts are presented in the form of easy-to-follow recipes.

Each chapter discusses separate types of recipes and they are presented with an increasing level of complexity from simple to advanced. All of these recipes can be used with JSF 1.2 as well.

This book helps you to find solutions to the most common aspects regarding JSF development with clear and easy-to-follow recipes


The JSF 2.0 Cookbook contains step-by-step instructions for JSF users to build desktop-style interfaces in their own web applications. The book is designed so that you can refer to it chapter by chapter, or you can look at the list of recipes and read them in no particular order.

Who this book is for

This book is for two types of audience:

  • Newcomers who know the basics of JSF but are yet to develop real JSF applications.
  • JSF developers who have previous experience but are lacking best practices and a standard way of implementing functionality

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software