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

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

  1. Create a bean named CreditCardBean:
    public class CreditCardBean
    {
        private String number;
        public CreditCardBean(String number)
        {
            this.number = number;
        }
        public String toString()
        {
            return number;
        }
    }
  2. Create the CreditCardConverter class to convert a string value into the CreditCardBean object and vice versa by implementing javax.faces.convert.Converter and org.primefaces.convert.ClientConverter:
    @FacesConverter("creditCardConverter")
    public class CreditCardConverter implements Converter, ClientConverter { private static final String CC_PATTERN = "^\\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