Chapter 10. Client-side Validation

In this chapter, we will cover the following topics:

  • Configuring and getting started with CSV
  • Instant validation with p:clientValidator
  • Bean Validation and transformation
  • Extending CSV with JSF
  • Extending CSV with Bean Validation

Introduction

Validation exists to ensure that the application is robust against all forms of input data. Invalid data can cause unexpected execution errors, break assumptions elsewhere in your application, introduce errors, and even let someone hijack your data to attack your software. Every software should have server-side validation.

In addition, validation on the client side enables quick feedback for the users without a round trip to the server. That means client-side validation is faster and enables the user to fix problems without sending input data to the server. We can say that server-side validation is a must-have and client-side validation is nice to have for every software.

In this chapter, we will learn how to implement Client-side Validation (CSV) with PrimeFaces. PrimeFaces Client Side Validation Framework is the most complete and advanced CSV solution for JavaServer Faces (JSF). It implements an API for JSF validation within the browser. This implementation is compatible with the server-side implementation so that users do not experience different behaviors on the client and server sides. They can use the same standard JSF validators and converters without worrying about implementation details. A few of the other features of PrimeFaces CSV are:

  • Supporting process and update attributes for AJAX
  • Utilizing PrimeFaces message components for CSV
  • Supporting i18n validation messages configured on the client side
  • Instant validation for various events
  • Integrating CSV with Bean Validation
  • Ease of writing custom validators and converters

    Note

    CSV only works for PrimeFaces components; standard h:* components are not supported.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.177.86