0

JSF – Individual Error Message for each field validated

This post demonstrates how to use individual error message for each field validated in JSF. Previously, we used “combined” error messages displayed in only one location on the page in

JSF – Basic Form Validation for Required Fields

For this post, we will reuse most of the stuff in that previous post. Modifying only registration page shown Registration Page - Request section.

Requirements

Stuff used in this post.

  • JSF 2.2
    • javax.faces-2.2.8.jar
  • JDK 8

Registration Page – Request

Note the for keyword in the <h:message for=".."/> . It refers to the <h:inputText/> ‘s id.

Testing

The required fields are Last Name and Email. In order to test with validation error, we’ll submit the page with only First Name provided.

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert