You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by extraquoo <ex...@gmail.com> on 2018/01/05 01:56:02 UTC
wicket switch locale to Spanish but dot is being ignored
Hi ,
my application supports the locale switch and when I am switching to Spanish
locale, the bigDecimal type textfield cannot be recognized the dot (eg.
555.555 is read as 555555 ).
The textfield code is:
final FormBorder q4Border = new FormBorder(
"questionFour",
new StringResourceModel("forms.cf37.question4", this, cf37Model));
pageTwoForm.add(q4Border);
q4Border.add(new TextField<BigDecimal>("question4.rentOrMortgageAmt").add(
new DecimalOnlyValidator()));
----------------------------------
the validator class is :
public class DecimalOnlyValidator extends AbstractValidator<BigDecimal>{
private static final long serialVersionUID = 1L;
@Override
protected void onValidate(IValidatable<BigDecimal> validatable) {
BigDecimal income = validatable.getValue();
if(null!=income){
Boolean matchesVal =income.toString().matches("[0-9]+([,.][0-9]{1,2})?");
if(!matchesVal){
super.error(validatable,"BigDecimalValidator.format");
}
}
}
}
The weird thing is the income object in the validator class cannot see the
dot of the amount. The dot is working perfectly for English locale(15.55 is
input in the page and income object is still 15.55), but for Spanish, the
dot is missing ( 15.55 input in the page and income object shows 1555 ).
the screenshot is below
<http://apache-wicket.1842946.n4.nabble.com/file/t375760/2018-01-04_17_54_08-Los_Angeles-Departamento_de_Servicios_Sociales_Publicos-Sus_Beneficios_Ahora.png>
<http://apache-wicket.1842946.n4.nabble.com/file/t375760/2018-01-04_17_55_04-PDLVDAPP124.png>
Can someone explain it and provide the solution ?
--
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: wicket switch locale to Spanish but dot is being ignored
Posted by extraquoo <ex...@gmail.com>.
I add a converter class and it works without impacting the message
resources.
Thank you so much.
--
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: wicket switch locale to Spanish but dot is being ignored
Posted by Sven Meier <sv...@meiers.net>.
Sorry, mixed up date with decimal:
add(new TextField<Double>("doubleProperty", Double.class) {
@Override
protected IConverter<?> createConverter(Class<?> type)
{
return new DoubleConverter() {
protected NumberFormat newNumberFormat(Locale
locale) {
return super.newNumberFormat(Locale.ENGLISH);
};
};
}
});
You could equally well just override Component#getLocale() to return
ENGLISH, but then message resources would be in English too.
Have fun
sven
Am 06.01.2018 um 02:26 schrieb extraquoo:
> why using getDateFormat() for the decimal/currency converter ? can you
> explain a little bit detailed?
>
> --
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: wicket switch locale to Spanish but dot is being ignored
Posted by extraquoo <ex...@gmail.com>.
why using getDateFormat() for the decimal/currency converter ? can you
explain a little bit detailed?
--
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: wicket switch locale to Spanish but dot is being ignored
Posted by Sven Meier <sv...@meiers.net>.
Hi,
override #newConverter() and let is return a subclass of DateConverter,
which overrides #getDateFormat() to return a DateFormat ignoring the
given locale.
Have fun
Sven
Am 05.01.2018 um 19:03 schrieb extraquoo:
> I understand. could you please show me any sample of such this custom
> converter?
>
> --
> 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: wicket switch locale to Spanish but dot is being ignored
Posted by extraquoo <ex...@gmail.com>.
I understand. could you please show me any sample of such this custom
converter?
--
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: wicket switch locale to Spanish but dot is being ignored
Posted by Sven Meier <sv...@meiers.net>.
Comma is the official decimal separator in Spanish:
https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html
If you want to change that you'll have to use a custom converter.
Sven
Gesendet mit Blue
Am 5. Jan. 2018, 06:40, um 06:40, extraquoo <ex...@gmail.com> schrieb:
>Hi ,
>
>my application supports the locale switch and when I am switching to
>Spanish
>locale, the bigDecimal type textfield cannot be recognized the dot (eg.
>555.555 is read as 555555 ).
>
>The textfield code is:
>
>final FormBorder q4Border = new FormBorder(
> "questionFour",
> new StringResourceModel("forms.cf37.question4", this, cf37Model));
> pageTwoForm.add(q4Border);
>
> q4Border.add(new
>TextField<BigDecimal>("question4.rentOrMortgageAmt").add(
>new DecimalOnlyValidator()));
>
>
>----------------------------------
>the validator class is :
>
>public class DecimalOnlyValidator extends
>AbstractValidator<BigDecimal>{
>
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void onValidate(IValidatable<BigDecimal> validatable) {
> BigDecimal income = validatable.getValue();
> if(null!=income){
> Boolean matchesVal
>=income.toString().matches("[0-9]+([,.][0-9]{1,2})?");
> if(!matchesVal){
> super.error(validatable,"BigDecimalValidator.format");
> }
>
> }
> }
>}
>
>The weird thing is the income object in the validator class cannot see
>the
>dot of the amount. The dot is working perfectly for English
>locale(15.55 is
>input in the page and income object is still 15.55), but for Spanish,
>the
>dot is missing ( 15.55 input in the page and income object shows 1555
>).
>the screenshot is below
><http://apache-wicket.1842946.n4.nabble.com/file/t375760/2018-01-04_17_54_08-Los_Angeles-Departamento_de_Servicios_Sociales_Publicos-Sus_Beneficios_Ahora.png>
>
><http://apache-wicket.1842946.n4.nabble.com/file/t375760/2018-01-04_17_55_04-PDLVDAPP124.png>
>
>
>Can someone explain it and provide the solution ?
>
>
>--
>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