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 custom Bean Validation annotation with the CSV framework

In this section, we will demonstrate how to create a custom CreditCard validator @CreditCard using the Bean Validation API, and show how to extend the PrimeFaces CSV framework to work with the custom Bean Validation annotation @CreditCard, by performing the following steps:

  1. Create a custom Bean Validation annotation @CreditCard:
    @Target({METHOD,FIELD,ANNOTATION_TYPE})
    @Retention(RUNTIME)
    @Constraint(validatedBy=CreditCardConstraintValidator.class)
    @ClientConstraint(resolvedBy=CreditCardClientValidationConstraint.class) @Documented public @interface CreditCard { String message() default "{com.packtpub.techbuzz.validation.creditcard.invalid}"; Class<?>[] groups() ...

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