You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by zkn <zk...@abv.bg> on 2012/10/08 21:33:45 UTC

tapestry.js formatLocalizedNumber

Hi,

I have a problem with French number formats in text fields. I've contributed my own translator for BigDecimal properties and it works fine except that I had to disable the JS validation.

The French number format looks like this: 100 000 000,00 where the grouping separator is space and decimal separator is comma.
But the grouping separator for French number format in JAVA is non-breaking space (ascii 160). Of course users cannot enter non-breaking space - they will just enter space.

So whenever I load a value in the textfield and save it back without changing spaces everything is ok. But if I enter any space the JS validation will fail.

Here is the code for formatLocalizedNumber

formatLocalizedNumber: function (number, isInteger) {
        /*
         * We convert from localized string to a canonical string, stripping out
         * group seperators (normally commas). If isInteger is true, we don't
         * allow a decimal point.
         */

        var minus = Tapestry.decimalFormatSymbols.minusSign;
        var grouping = Tapestry.decimalFormatSymbols.groupingSeparator;
        var decimal = Tapestry.decimalFormatSymbols.decimalSeparator;

I couldn't find where  Tapestry.decimalFormatSymbols.groupingSeparator is being set. I guess Tapestry uses JAVA's decimalFormatSymbols but I don't know how and where.

May be I can fix the problem by adding new validator to Tapestry.Validator. 

Or should I open a ticket to get this fixed in the Tapestry distribution?

Regards,

Özkan

Re: tapestry.js formatLocalizedNumber

Posted by zkn <zk...@abv.bg>.
Thanks! That worked.

On 09.10.2012, at 10:58, Lance Java wrote:

> I've had troubles with this sort of thing before with other web frameworks
> before where this was very difficult to do. These locale specific
> date/number formats are stored in prop files that are part of the jre
> installation and with other web frameworks I was forced to use hacky
> workarounds.
> 
> Luckily, tapestry is made up of overridable services so you're in luck!
> You'll need to override (or perhaps decorate) NumericTranslatorSupport. I
> suggest you take a look at the source for NumericTranslatorSupportImpl [1]
> which is responsible for initializing Tapestry.decimalFormatSymbols on the
> client.
> 
> NB. The service interface is in a package marked "internal" and is therefore
> considered part of the private API and therefore may be changed in a way
> that is not backward compatible without notice. Your need to override this
> service might flag that public API needs to be improved.
> 
> [1]
> https://github.com/apache/tapestry5/blob/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/translator/NumericTranslatorSupportImpl.java
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/tapestry-js-formatLocalizedNumber-tp5716714p5716720.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: tapestry.js formatLocalizedNumber

Posted by Lance Java <la...@googlemail.com>.
I've created a jira here https://issues.apache.org/jira/browse/TAP5-2011



--
View this message in context: http://tapestry.1045711.n5.nabble.com/tapestry-js-formatLocalizedNumber-tp5716714p5716722.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: tapestry.js formatLocalizedNumber

Posted by Lance Java <la...@googlemail.com>.
I've had troubles with this sort of thing before with other web frameworks
before where this was very difficult to do. These locale specific
date/number formats are stored in prop files that are part of the jre
installation and with other web frameworks I was forced to use hacky
workarounds.

Luckily, tapestry is made up of overridable services so you're in luck!
You'll need to override (or perhaps decorate) NumericTranslatorSupport. I
suggest you take a look at the source for NumericTranslatorSupportImpl [1]
which is responsible for initializing Tapestry.decimalFormatSymbols on the
client.

NB. The service interface is in a package marked "internal" and is therefore
considered part of the private API and therefore may be changed in a way
that is not backward compatible without notice. Your need to override this
service might flag that public API needs to be improved.

[1]
https://github.com/apache/tapestry5/blob/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/translator/NumericTranslatorSupportImpl.java



--
View this message in context: http://tapestry.1045711.n5.nabble.com/tapestry-js-formatLocalizedNumber-tp5716714p5716720.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org