Real-Time Validation

As we saw in the section “Form Completion,” on page 9, you can implement basic Ajax in a JSF application with little more than a servlet and a few lines of JavaScript. In this example, we’ll implement real-time validation, which will give us the opportunity to explore some of the more complex interactions between Ajax and JSF.

The application shown in Figure 3 performs real-time validation. When the user enters the fifth character of the Zip Code, we execute an Ajax request to validate those five digits.

Figure 3. Real-time validation

image

On the server, we obtain a reference to the component that represents the Zip Code field ...

Get AJAX and JavaServer™ Faces now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.