O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using the CSV framework with the Bean Validation API

Let us see how we can use the Bean Validation API to specify validation constraints and perform validations using PrimeFaces client-side validations, by performing the following steps:

  1. Create the UserBean class and specify the validation constraints using the Bean Validation API annotations:
    public class UserBean
    {
        private Integer id;
        @Pattern(regexp="^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$", message="Invalid Email Id")
        private String emailId;
        @Size(min=2,max=5)  
        private String password;
        @Size(min=1, message="FirstName should not be empty")
        private String firstName;
        private String lastName;
     @Pattern(regexp="^\\d{3}-\\d{3}-\\d{4}$") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required