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 JSF validator on the client side

Let us see how we can create a custom JSF validator and use it with the PrimeFaces CSV framework, by performing the following steps:

  1. Create the CreditCardValidator class to validate whether the credit card number is in the 9999 9999 9999 9999 format or not:
    import java.util.*;
    import java.util.regex.Pattern;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.validator.FacesValidator;
    import javax.faces.validator.Validator;
    import javax.faces.validator.ValidatorException;
    import org.primefaces.validate.ClientValidator; @FacesValidator("creditCardValidator") public class CreditCardValidator ...

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