[seam-issues] [JBoss JIRA] Updated: (SEAMFACES-24) Provide convenience classes for Validators/Converters

Lincoln Baxter III (JIRA) jira-events at lists.jboss.org
Wed Jun 9 00:25:38 EDT 2010


     [ https://jira.jboss.org/browse/SEAMFACES-24?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lincoln Baxter III updated SEAMFACES-24:
----------------------------------------

    Component/s: Validation & Conversion


> Provide convenience classes for Validators/Converters
> -----------------------------------------------------
>
>                 Key: SEAMFACES-24
>                 URL: https://jira.jboss.org/browse/SEAMFACES-24
>             Project: Seam Faces
>          Issue Type: Feature Request
>          Components: Validation & Conversion
>            Reporter: Lincoln Baxter III
>             Fix For: 3.0.0.Alpha4
>
>
> Provide generic abstract classes implementing Validator and Converter, for convenient removal of typecasting. Work will need to be done to figure out how to best handle ClassCastExceptions in the case when the provided value argument is not of the type required.
> --------------------------------------------------------------------------------------------------------------------------------------
> public abstract class Converter<T> implements javax.faces.convert.Converter
> {
>    FacesContext context;
>    public abstract T toObject(UIComponent comp, String value);
>    public abstract String toString(UIComponent comp, T value);
>    @Override
>    public Object getAsObject(final FacesContext context, final UIComponent comp, final String value)
>    {
>       this.context = context;
>       return toObject(comp, value);
>    }
>    @Override
>    @SuppressWarnings("unchecked")
>    public String getAsString(final FacesContext context, final UIComponent comp, final Object value)
>    {
>       this.context = context;
>       return toString(comp, (T) value);
>    }
>    public FacesContext getContext()
>    {
>       return context;
>    }
> }
> ---------------------------------------------------------------------------------------------------------------------------------------
> public abstract class Validator<T> implements javax.faces.validator.Validator
> {
>    FacesContext context;
>    public abstract void validate(UIComponent component, T value) throws ValidatorException;
>    @Override
>    @SuppressWarnings("unchecked")
>    public void validate(final FacesContext context, final UIComponent component, final Object value) throws javax.faces.validator.ValidatorException
>    {
>       this.context = context;
>       validate(component, (T) value);
>    }
>    public FacesContext getContext()
>    {
>       return context;
>    }
> }
> ---------------------------------------------------------------------------------------------------------------------------------------
> Provide extension of ValidatorException to remove need for creating new FacesMessage objects when throwing ValidatorExceptions from Validators.
> public class ValidatorException extends javax.faces.validator.ValidatorException
> {
>    public ValidatorException(final String message)
>    {
>       super(new FacesMessage(message));
>    }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list