- java.lang.Object
-
- org.omnifaces.converter.TrimConverter
-
- Direct Known Subclasses:
ToLowerCaseConverter
,ToUpperCaseConverter
public class TrimConverter extends Object implements Converter<String>
The
omnifaces.TrimConverter
is intented to trim any whitespace from submittedString
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 theconverter
attribute of the component referring theString
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
-
-
Field Summary
-
Fields inherited from interface jakarta.faces.convert.Converter
DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE_PARAM_NAME
-
-
Constructor Summary
Constructors Constructor Description TrimConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAsObject(FacesContext context, UIComponent component, String submittedValue)
String
getAsString(FacesContext context, UIComponent component, String modelValue)
-
-
-
Method Detail
-
getAsObject
public String getAsObject(FacesContext context, UIComponent component, String submittedValue)
- Specified by:
getAsObject
in interfaceConverter<String>
-
getAsString
public String getAsString(FacesContext context, UIComponent component, String modelValue)
- Specified by:
getAsString
in interfaceConverter<String>
-
-