Book Image

JSF 1.2 Components

By : IAN HLAVATS
Book Image

JSF 1.2 Components

By: IAN HLAVATS

Overview of this book

Today's web developers need powerful tools to deliver richer, faster, and smoother web experiences. JavaServer Faces includes powerful, feature-rich, Ajax-enabled UI components that provide all the functionality needed to build web applications in a Web 2.0 world. It's the perfect way to build rich, interactive, and "Web 2.0-style" Java web apps. This book provides a comprehensive introduction to the most popular JSF components available today and demonstrate step-by-step how to build increasingly sophisticated JSF user interfaces with standard JSF, Facelets, Apache Tomahawk/Trinidad, ICEfaces, JBoss Seam, JBoss RichFaces/Ajax4jsf, and JSF 2.0 components. JSF 1.2 Components is both an excellent starting point for new JSF developers, and a great reference and “how to” guide for experienced JSF professionals. This book progresses logically from an introduction to standard JSF HTML, and JSF Core components to advanced JSF UI development. As you move through the book, you will learn how to build composite views using Facelets tags, implement common web development tasks using Tomahawk components, and add Ajax capabilities to your JSF user interface with ICEfaces components. You will also learn how to solve the complex web application development challenges with the JBoss Seam framework. At the end of the book, you will be introduced to the new and up-coming JSF component libraries that will provide a road map of the future JSF technologies.
Table of Contents (14 chapters)
JSF 1.2 Components
Credits
Foreword
About the Author
About the Reviewers
Preface

Preface

Java developers and Web designers today need more powerful tools to deliver the richer, faster, and smoother web experience that users now demand. JavaServer Faces is an advanced web application framework that includes hundreds of powerful, feature-rich, Ajax-enabled UI components that provide all of the functionality needed to build web applications in a Web 2.0 world.

There has never been a better time to learn JSF. The JSF ecosystem is growing fast and the abundance of JSF components, development tools, industry conferences, and job opportunities is impressive. Learning JSF can be a challenge, but this book makes it easy by showing you the most important JSF technologies and concepts that you need to know to become a JSF professional.

What this book covers

Chapter 1:Standard JSF Components introduces you to the JavaServer Faces framework and the key concepts that you need to understand to build simple JSF applications. You will learn about Model-View-Controller, managed beans, the JSF expression language, converters, and validators. You will also discover how to use the standard JSF user interface components (such as text fields, radio buttons, selection lists, and checkboxes) to receive text, date/time, numeric, and other types of input from users as well as handle form submission, render messages, lay out components in a grid, and display a data table.

Chapter 2:Facelets Components introduces the Facelets view definition framework and compares it to JSP as the view technology for JSF. You will learn about working with valid XHTML documents and will see examples of how to use the Facelets framework to create simple and complex composite user interfaces based on Facelets templates. You will also learn how to use the Facelets component library to display debugging information, iterate data, include and remove UI components and markup, pass parameters between Facelets pages, create reusable view elements, and apply advanced Facelets templating concepts.

Chapter 3:Apache MyFaces Tomahawk Components covers the Apache MyFaces Tomahawk component library and looks at how to use Tomahawk components such as calendars, trees, a file upload component, and navigation menus to solve common web development tasks. You will learn how to use Tomahawk components to validate user input, accept date/time input, upload files, render tree components, create navigation menus, implement user interface security, display sortable data tables, and use newspaper layouts.

Chapter 4:Apache MyFaces Trinidad Components discusses the Apache MyFaces Trinidad framework and Ajax technology and will introduce you to many of the 100 plus rich user interface controls in this powerful component library. You will learn how to use color choosers, pop-up calendars, dynamic trees, data tables, a number spinbox, shuttle components, navigation menus, layout panels, and more, to implement typical web development use cases. You will also learn how to use the Apache MyFaces Trinidad dialog framework to add dialog windows to your application, how to enable Trinidad's client-side JavaScript validation, how to create dynamic navigation menus, how to design custom skins and icons for Trinidad's skinning framework, and how to use Trinidad's partial page rendering (PPR) Ajax feature to enhance your JSF pages.

Chapter 5:ICEfaces Components introduces the ICEfaces Ajax component library, and explains many of the important concepts that you need to know in order to develop JSF applications based on ICEfaces. You will learn how to use many of the more than 50 Ajax-enabled user interface components in the ICEfaces component library, such as how to add dynamic effects to your pages to enhance input validation, how to use navigation and context menus, how to work with tree components, how to render dynamic data tables that support sorting and paging, how to render pie charts and bar graphs, how to create a tabbed user interface, how to arrange elements using drag-and-drop, how to lay out components in a grid, and how to work with modal dialogs.

Chapter 6:JBoss Seam Components covers the JBoss Seam framework and introduces you to the fundamentals of building JSF applications that use the full Java Enterprise Edition (Java EE) technology stack. You will learn how to configure Seam, how to apply Seam annotations to Java classes, and how to use Seam JSF controls to bridge the gap between Enterprise JavaBeans (EJB3) components, the Java Persistence API (JPA), and the JSF framework. This chapter will show you how to validate user input efficiently using Seam, JPA, and the Hibernate Validator framework. You will also discover how to use the Seam tag library and Java API to display validation and success messages, render required field decorations, display debugging information, use Seam's conversation management feature to implement robust JSF workflows, and how to combine Seam with JBoss RichFaces and Ajax4jsf to build next generation JSF applications.

Chapter 7:JBoss RichFaces and Ajax4jsf Components covers the JBoss RichFaces and Ajax4jsf component libraries. You will learn how to use many advanced RichFaces components such as in-place editable text, a calendar, an Ajax-based auto-complete suggestion box, rich panel and menu components, a Google map component, a Microsoft Virtual Earth component, dynamic data tables with sorting and paging, data grids, a color picker, a slider component, a number spinner, a picklist control, a rich text editor, and more. You will also learn how to add Ajax support to non-Ajax JSF components with Ajax4jsf, and how to perform advanced Ajax tasks such as submitting forms asynchronously, submitting one component at a time, polling the server, and re-rendering parts of the page after an Ajax request.

Appendix:Learning JSF: Next Steps introduces JavaServer Faces 2.0 and provides a summary of the key features in the next generation of the JSF framework. You will discover how JSF 2.0 emphasizes convention over configuration by learning about the new JSF annotations to simplify managed bean configuration and reduce XML, the new JSF resource loading mechanism, the simplified navigation mapping convention, the integration of Facelets into the core JSF framework, the new "composite" JSF tag library for defining composite components, and the significantly improved support for Ajax that is now built-in to the framework. You will also learn about PrimeFaces, a promising new JSF component library.

What you need for this book

To run the example applications included with this book, you will need a Java Servlet/JSP container that supports JSF 1.2 such as Apache Tomcat 6.0 (http://tomcat.apache.org) and a Java EE container such as JBoss Application Server 4.2 (http://www.jboss.org).

The example applications were developed using Eclipse IDE for Java EE Developers (Galileo Release) (http://www.eclipse.org), Adobe Dreamweaver CS4 (http://www.adobe.com), and JSFToolbox for Dreamweaver 3.5 (http://www.jsftoolbox.com). You will also need the MySQL 5.1 database (http://www.mysql.org). The example applications can be downloaded from the publisher's website (http://www.packtpub.com).

Conventions

In this book, you will 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 are shown as follows: "The following example demonstrates some of the context parameters that we set in web.xml to enable the Facelets ViewHandler."

A block of code will be set as follows:

<application>
<message-bundle>messages</message-bundle>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>fr</supported-locale>
<supported-locale>es</supported-locale>
</locale-config>
</application>

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

<h:inputText id="emailAddress" value="#{customerBean.customer.emailAddress}" required="#{true}">
<t:validateEmail message="The email address you have entered is not valid." />
</h:inputText>

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 our text like this: "First let's examine the code for the Cancel button."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

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 drop an email to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

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 for the book

Note

Visithttp://www.packtpub.com/files/code/7627_Code.zip to directly download the example code.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or 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 to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

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.