THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
protected void init() { super.init(); IApplicationSettings settings = getApplicationSettings(); settings.setConverterFactory(new IConverterFactory() { public IConverter newConverter(final Locale locale) { final Converter converter = new Converter(locale); final StringConverter stringConverter = new StringConverter(); final DateToStringConverter dateToStringConverter = new DateToStringConverter(); dateToStringConverter.setDateFormat(locale, new SimpleDateFormat("dd/MM/yy")); stringConverter.set(Date.class,dateToStringConverter); final DateConverter dateConverter = new DateConverter(false); // set lenient to false for dateformat so that strict pasrsing is done. final DateFormat format = new SimpleDateFormat("dd/MM/yy"); format.setLenient(false); dateConverter.setDateFormat(locale, format); converter.set(Date.class,dateConverter); converter.set(String.class,stringConverter); return converter; } }); } |
In Wicket 1.3
Override init() method in Application class to modify IApplicationSettings.
Code Block |
---|
protected void init() {
super.init();
IApplicationSettings settings = getApplicationSettings();
settings.setConverterLocatorFactory(new IConverterLocatorFactory()
{
public IConverterLocator newConverterLocator()
{
return new MyCustomConverterLocator();
}
});
}
|
The ConverterLocator looks like this
Code Block |
---|
/**
* Custom {@link org.apache.wicket.IConverterLocator} that extends the
* default {@link ConverterLocator} from wicket.
*/
public class MyCustomConverterLocator extends ConverterLocator
{
public MyCustomConverterLocator()
{
set(Money.class, new MoneyConverter());
}
}
|
Providing a custom converter for specific components
...