Software Development

JSF – Individual Error Message for each field validated

This post demonstrates how to use individual error messages 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 the 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. To test with a validation error, we’ll submit the page with only First Name provided.

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like