> I commented the lines that define the datetostring converter
> and the effect was that the date was displayed using toString()
> and the float value was displayed correctly.
> So, how can I define converters for different types,
> like
> Float and Date from and to String?.
Like I answered you earlier:
getApplicationSettings().setConverterFactory(new
IConverterFactory()
{
public IConverter newConverter(final Locale locale)
{
final Converter converter = new
Converter(locale);
// String -> Date
DateConverter dc = new DateConverter();
dc.setDateFormat(locale, new
SimpleDateFormat("dd-MM-yyyy"));
converter.set(Date.class, dc);
// Date -> String
DateToStringConverter dsc = new
DateToStringConverter();
dsc.setDateFormat(locale, new
SimpleDateFormat("dd-MM-yyyy"));
StringConverter sc = new StringConverter();
sc.set(Date.class, dsc);
converter.set(String.class, sc);
return converter;
}
});
Notice the use of a seperate StringConverter that has a registry for
type converters itself.
In a previous post I
> learnt that that the conversion was a two-way process, that
> is from type1->type2 and from type2->type1, and that was
> applicable to a textfield.
> I'm lost here.
It is. Currently Wicket doesn't know about ingoing or outgoing values
though. But typically conversion is from String to T and from T to
String. Different converters would be used in both cases.
Eelco
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user