You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vishal Popat <vi...@cipriati.co.uk> on 2018/08/16 07:26:07 UTC
Set Double to more than 3 digits in AjaxEditableLabel
Hi,
In Wicket 6.29.0, I did the following within a class that extended AjaxEditableLabel
@Override
public IConverter<Double> getConverter(Class clazz) {
DoubleConverter converter = (DoubleConverter)DoubleConverter.INSTANCE;
NumberFormat format = converter.getNumberFormat(getLocale());
format.setMaximumFractionDigits(12);
converter.setNumberFormat(getLocale(), format);
return converter;
}
In Wicket 7.10.0, converter.setNumberFormat no longer exists. I am not sure what I need to do to increase the fraction digit to 12 as it is currently set to 3.
Any help would be appreciated.
Vishal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Set Double to more than 3 digits in AjaxEditableLabel
Posted by Martin Grigorov <ma...@gmail.com>.
Yes, it should have been super.newNumberFormat(locale)
On Fri, Aug 17, 2018, 09:27 vp143 <vi...@cipriati.co.uk> wrote:
> Thanks Martin, that worked great!
>
> Just for completeness, I needed to make a slight modification as I did not
> find super.createNumberFormat
>
> DoubleConverter dc = new DoubleConverter() {
> @Override
> protected NumberFormat newNumberFormat(final Locale
> locale) {
> NumberFormat format =
> NumberFormat.getInstance(locale);
> format.setMaximumFractionDigits(12);
> return format;
> }
> };
>
> --
> Sent from:
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Set Double to more than 3 digits in AjaxEditableLabel
Posted by vp143 <vi...@cipriati.co.uk>.
Thanks Martin, that worked great!
Just for completeness, I needed to make a slight modification as I did not
find super.createNumberFormat
DoubleConverter dc = new DoubleConverter() {
@Override
protected NumberFormat newNumberFormat(final Locale locale) {
NumberFormat format = NumberFormat.getInstance(locale);
format.setMaximumFractionDigits(12);
return format;
}
};
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Set Double to more than 3 digits in AjaxEditableLabel
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
The way you did this will mutate the singleton instance.
The recommended way is to instantiate it yourself and override
org.apache.wicket.util.convert.converter.AbstractDecimalConverter#newNumberFormat
I.e.
DoubleConverter dc = new DoubleConverter() {
@Override protected NumberFormat newNumberFormat(final Locale locale) {
NumberFormat format = super.createNumberFormat(getLocale());
format.setMaximumFractionDigits(12);
return format;
}
}
On Thu, Aug 16, 2018 at 10:26 AM Vishal Popat <vi...@cipriati.co.uk>
wrote:
> Hi,
>
> In Wicket 6.29.0, I did the following within a class that extended
> AjaxEditableLabel
>
> @Override
> public IConverter<Double> getConverter(Class clazz) {
> DoubleConverter converter =
> (DoubleConverter)DoubleConverter.INSTANCE;
> NumberFormat format = converter.getNumberFormat(getLocale());
> format.setMaximumFractionDigits(12);
> converter.setNumberFormat(getLocale(), format);
> return converter;
> }
>
> In Wicket 7.10.0, converter.setNumberFormat no longer exists. I am not
> sure what I need to do to increase the fraction digit to 12 as it is
> currently set to 3.
>
> Any help would be appreciated.
>
> Vishal
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>