Converter for java.lang.String
I've built a converter for the class java.lang.String as follows:
package org.wildjava.gecko.jsf.util.converter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
/**
* @author Diego Trombetta
* @since 1.0.0
*/
publicclass StringConverterimplements javax.faces.convert.Converter{
publicstaticfinal String CONVERTER_ID ="org.wildjava.gecko.String";
/**
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
*javax.faces.component.UIComponent, java.lang.String)
*/
public Object getAsObject(FacesContext context, UIComponent component,
String value){
try{
if (context ==null || component ==null)
thrownew NullPointerException();
if (value ==null)
returnnull;
value = value.trim();
if (value.length() < 1)
returnnull;
return value;
}catch (Exception exception){
thrownew ConverterException(exception);
}
}
/**
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
*javax.faces.component.UIComponent, java.lang.Object)
*/
public String getAsString(FacesContext context, UIComponent component,
Object obj){
try{
if (context ==null || component ==null)
thrownew NullPointerException();
if (obj ==null)
return"";
return obj.toString().trim();
}catch (Exception exception){
thrownew ConverterException(exception);
}
}
}
and I've written in my facesconfig.xml the following configuration code:
<converter>
<converter-for-class>java.lang.String</converter-for-class>
<converter-class>
org.wildjava.gecko.jsf.util.converter.StringConverter
</converter-class>
</converter>
but the converter is never invoked.
Am I missing something?
I've done the same stuff with other classes and everything worked fine!
Is the java.lang.String class different for some reasons?

