Chapter 9. JSF front-end scenario 259
In the case of the ITSOMart application, we define the CustomerDO class as the
managed bean responsible for storing session data. The class stores the basic
customer data carried through multiple screens in the application.
9.3.3 JSF input validation
The JSF framework provides a variety of ways of validating user input. This
section discusses some of these options, and describes the ones employed in
the ITSOMart application. Implementation details for the various validation
options are presented later in 9.4.6, “Implementing input validation” on page 280.
Client side versus server side validation
Before looking into the various JSF validation options, we first discuss one of
known limitations. JSF currently does not support client side validation. That
means that even the most simple of input format checking requires validation to
be performed on the server. This goes against the common practice for
Web-based applications, where simple input validation is often done on the client
side, using JavaScript.
The options in this case, are to stick with standard JSF validation, or manually
program client side validation with JavaScript. The JSF-based validation will fit in
naturally with the tooling and the framework, but the JavaScript client side
validation reduces the server load. Either option is valid, and the choice will
depend on the relative importance of reducing server load for the application in
question.
In the ITSOMart front-end, we have chosen to use JSF-based validation to
demonstrate this technique. Note that the specifications for the upcoming JSF2.0
release will include client-side validation, which should remedy the current
shortcoming.
Standard component validation
Most JSF UI components include at least some level of input validation. These
include checks for required values, string length, and date formats. These are not
comprehensive, but they do offer some useful basic functionality. The ITSOMart
front-end makes use of all appropriate standard validation provided by the JSF
components.
Custom validation
The validation provided in the standard JSF components is limited to basic data
types such as strings, numbers, and dates. Clearly this is not sufficient for most
complex applications. However, JSF does provide a simple framework for
specifying custom-defined validation functions. Once a special validation class is

Get Patterns: Implementing Self-Service in an SOA Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.