From the course: Java EE: JavaServer Faces JSF

Unlock the full course today

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

Custom validation in JSF

Custom validation in JSF

From the course: Java EE: JavaServer Faces JSF

Start my 1-month free trial

Custom validation in JSF

- [Instructor] Let's build a custom JSF validator. It's really straightforward. We'll implement a validator that will reject text input that contains the word Select. We'll supply this validator to the inputTextarea on our input components listing page. I've created a standard Java class. We'll turn this into a validator. First we add the @FacesValidator annotation. So, @FacesValidator, let's fix that import. The validator comes from the javax.faces.validator.FacesValidator package. Adding this validator means we're advertising to the JSF runtime and this class is a validator and it should be made available on any Facelets page. Next we'll implement the Validator Interface from the javax.faces.validator package. So, let's implement the validator. Let's Fix that import. We certainly don't want the one from javax.validation.Validator. We want javax.faces.validator.Validator. There we go. Now, to implement the interfaces abstract methods. Now, the validate method is what's called by the…

Contents