RichFaces 3.3.1 BETA2 Available.
Beta2 of Richfaces 3.3.1 is available.
Add your own converter in RichFaces
Posted by Julien in Developements, Richfaces on March 19th, 2009
First, you may create class “MyConverter.java” for example, this class must implements Converter with two methods.
package my.converter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
public class MyConverter implements Converter {
public MyConverter() {
}
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
return (Object)arg2;
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
return arg2.toString();
}
}
Second, add your converter to your faces-config.xml.
<converter>
<converter-id>MyConverter</converter-id>
<converter-class>my.converter.MyConverter</converter-class>
</converter>
Third, add MyConverter.class in WEB-INF/classes/ in your War file.
To finish use it in your xhtml with the tag :
<f:converter converterId="MyConverter" />
Welcome on my personal blog.
Personal blog of julien colin.
