Book Image

JSF 2.0 Cookbook

By : Anghel Leonard
Book Image

JSF 2.0 Cookbook

By: Anghel Leonard

Overview of this book

<p>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.<br /><br />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.<br /><br />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. <br /><br />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.<br /><br />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.</p>
Table of Contents (19 chapters)
JSF 2.0 Cookbook
Credits
About the Author
About the Reviewer
Preface
Index

Apache MyFaces Commons validators


The Apache MyFaces Commons project contains a set of validators (myfaces-validators), converters (myfaces-converters), and utils (myfaces-commons-utils). These are JARs that can be used with any JSF framework.

In this recipe, we are using validators. The most widely used validators are:

  • <mcv:validateCSV>

  • <mcv:validateCompareTo>

  • <mcv:validateCreditCard>

  • <mcv:validateDateRestriction>

  • <mcv:validateEmail>

  • <mcv:validateISBN>

  • <mcv:validateRegExpr>

  • <mcv:validateUrl>

In this recipe you will see how to use the mcv:validateEmail validator. Based on this example, it will be simple to work with the rest of the validators.

Getting ready

We developed this recipe with NetBeans 6.8, JSF 2.0, and GlassFish v3. The JSF 2.0 classes were obtained from the NetBeans JSF 2.0 bundled library. In addition, we have used Apache MyFaces Commons 1.2, which is designed for JSF 1.2, but it seems that it supports JSF 2.0 also...