Of the many new features of JSF 2, the most compelling of the two features are controversial composite components and Ajax support. But the strength of their combination is obvious: it is easy to implement AJAX-enabled custom components.
About this series
The JSF Fu series is based on the concept of David Geary's introductory article with the same name. This series will delve into JSF 2 and its ecosystem, and will also explain how to integrate some Java EE technologies, such as contexts and Dependency injection, with JSF.
In this article, I'll show you how to implement the AutoComplete component, which will use Ajax to manage its completion list. In this process, you will learn how to integrate Ajax into your own composite component.
The code in this series is based on JSF 2, which runs in enterprise containers such as GlassFish or Resin. The last part of this article discusses in detail how to use GlassFish to install and run the code for this article.
JSF automatically completes custom components
The Automatic completion field (also known as the Suggestion Box), which is famous for Google search fields, is a combination of many Web applications. They are also typical applications of Ajax. AutoComplete fields are accompanied by a number of Ajax frameworks, such as scriptaculous and JQuery, such as the automated component integration of Figure 1-ajaxdaddy-as shown in:
Figure 1. Ajaxdaddy Auto-Complete components
This article discusses how to use JSF to implement an Ajax-enabled AutoComplete field. You'll see how to implement the AutoComplete field as shown in Figure 2, which will display a short list of virtual countries:
Figure 2. Auto Complete fields