From the course: Java EE 8: JavaServer Faces JSF 2.3

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Whole bean validation in JSF 2.3

Whole bean validation in JSF 2.3

From the course: Java EE 8: JavaServer Faces JSF 2.3

Start my 1-month free trial

Whole bean validation in JSF 2.3

- [Instructor] Validating user input has always been a part of JSF. Validating multiple fields on a page also comes out of the box. As long as those fields don't depend on each other or their validity isn't interdependent, you're good. Taking this page, for example, I have the First Name, Last Name, Password, and Confirm Password fields. Now, if I want to validate all these fields as a unit, that's where JSF 2.3's class level validation comes in. Class level validation is supported by the Bean Validation API. So the first thing to do is enable the feature in the web.xml file. So go over here to the web.xml. We use some existing markup. The parameter is a javax.faces.ENABLE_VALIDATE_WHOLE_BEAN. Save it. Set that to true. Very good. An entity class like this UserRegistrationPOJO that I have here will benefit from Whole Bean Validation. So this POJO here has the firstName, lastName, password1, password2. So this…

Contents