Created
October 23, 2014 14:13
-
-
Save struberg/459ccc234cea01edc89b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FacesConverter(forClass = String.class) | |
public class StringConverter implements Converter{ | |
@Override | |
public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException { | |
if (component instanceof HtmlInputText || component instanceof HtmlInputTextarea) { | |
return (value != null) ? StringUtils.trimToNull(value) : null; | |
} | |
return value; | |
} | |
@Override | |
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { | |
return (value != null) ? value.toString() : null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment