Class TrimConverter

java.lang.Object
org.omnifaces.converter.TrimConverter
All Implemented Interfaces:
Converter<String>
Direct Known Subclasses:
ToLowerCaseConverter, ToUpperCaseConverter

public class TrimConverter extends Object implements Converter<String>

The omnifaces.TrimConverter is intented to trim any whitespace from submitted String values. This keeps the data store free of whitespace pollution.

This converter does by design no conversion in getAsString().

Usage

This converter is available by converter ID omnifaces.TrimConverter. Just specify it in the converter attribute of the component referring the String property. For example:

 <h:inputText value="#{bean.username}" converter="omnifaces.TrimConverter" />
 

Since OmniFaces 4.5 it's also available by <o:trimConverter> tag.

 <h:inputText value="#{bean.username}">
     <o:trimConverter />
 </h:inputText>
 

You can also configure it application wide via below entry in faces-config.xml without the need to specify it in every single input component:

 <converter>
     <converter-for-class>java.lang.String</converter-for-class>
     <converter-class>org.omnifaces.converter.TrimConverter</converter-class>
 </converter>
 
Since:
2.6
Author:
Bauke Scholtz