CreditCardConverter Class accepts a Credit Card Number of type String
and strips blanks and "-" if any from it. It also formats the
CreditCardNumber such a blank space separates every four characters.
Blanks and "-" characters are the expected demiliters
that could be used as part of a CreditCardNumber.
getAsObject(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
String newValue)
Parses the CreditCardNumber and strips any blanks or "-"
characters from it.
getAsString(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
Formats the value by inserting space after every four characters
for better readability if they don't already exist.
public static final StringCONVERSION_ERROR_MESSAGE_ID
The message identifier of the Message to be created if
the conversion fails. The message format string for this
message may optionally include a {0} and
{1} placeholders, which
will be replaced by the object and value.
public ObjectgetAsObject(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
String newValue)
throws javax.faces.convert.ConverterException
Parses the CreditCardNumber and strips any blanks or "-"
characters from it.
Specified by:
getAsObject in interface javax.faces.convert.Converter
Throws:
javax.faces.convert.ConverterException
getAsString
public StringgetAsString(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
throws javax.faces.convert.ConverterException
Formats the value by inserting space after every four characters
for better readability if they don't already exist. In the process
converts any "-" characters into blanks for consistency.
Specified by:
getAsString in interface javax.faces.convert.Converter