Hi Blake, looks like:
http://bugs.sun.com/view_bug.do?bug_id=6318800 -Matthias On Nov 30, 2007 7:25 PM, Matthias Wessendorf <[EMAIL PROTECTED]> wrote: > Blake, > > out of the blue, but perhaps that is a JDK bug? > > I am on 1.5.0_11 > > > On Nov 30, 2007 7:14 PM, Blake Sullivan <[EMAIL PROTECTED]> wrote: > > > > Matthias, > > > > I must be missing something. Adam > > org.apache.myfaces.trinidad.convert.NumberConverter.getAsObject() to convert > > the spaces that the user might have typed in to the non-breaking spaces that > > the NumberFormat expects if the grouping character is a non-breaking space. > > > > > > <tr:inputText value="#{validate.currency}" > > id="outputText1"> > > <tr:convertNumber locale="fr_FR" type="currency"/> > > </tr:inputText> > > > > The rendered output is "12 345,68 €", which is fine. > > > > When re-submitting this value, you'll see an converter-error-msg, that > > the format is wrong. > > That is because: > > 1. the groupingSeparator() in fr_FR is '\u00a0' > > 2. therefore the " " between 2 and 3 AND 8 and € is replaced by '\u00a0'. > > > > > > I don't understand why this fails. Isn't the code Adam added explicitly > > designed to make this work, by replacing the spaces with non-breaking spaces > > before feeding the String to be converted to the NumberFormat? > > > > -- Blake Sullivan > > > > > > > > > > Matthias Wessendorf wrote: > > I looked at this again this morning: > > A simple Java-test fails and shows why: > > > > Doing this: > > > > String va = "12 345,68 €"; > > NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE); > > Number n = (Number) nf.parseObject(va); > > > > and you'll see that n is NULL. > > > > Why? > > So, here it is: > > the String va contains to blanks (" "), which are between 2 and 3, and > > between 8 and € as well. > > > > In fr_FR, however, the *grouping separator * is not " ", but it is a > > special char for blank (\u00a0). > > So, my little test will pass, when the first BLANK is replaced by the > > special char... > > > > I thought, that the NumberFormat actually does parse the object for me. > > Looks like (for fr_FR) I have to create a *custom parser*... Which is odd, > > IMO > > > > Now, do this: > > > > String va1 = "12 345,68 €"; > > NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.FRANCE); > > String va2 = nf.format(12345.68)); > > System.out.println(va1.equals(va2)); > > > > and you see, what the issue is... > > > > Anyway, anyone that has an idea on that one? > > > > Thx! > > Matthias > > On Nov 28, 2007 10:51 AM, Matthias Wessendorf <[EMAIL PROTECTED]> wrote: > > > > > > for fixing Trinidad-202 ([1] (was done during incubation)), we added > > these lines (and some other) > > > > DecimalFormat df = (DecimalFormat)fmt; > > DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); > > > > if (dfs.getGroupingSeparator() == '\u00a0') > > value = value.replace(' ', '\u00a0'); > > > > So far, so good. > > But that causes issues, when running in "fr_FR" locale, like: > > > > <tr:inputText value="#{validate.currency}" > > id="outputText1"> > > <tr:convertNumber locale="fr_FR" type="currency"/> > > </tr:inputText> > > > > The rendered output is "12 345,68 €", which is fine. > > > > When re-submitting this value, you'll see an converter-error-msg, that > > the format is wrong. > > That is because: > > 1. the groupingSeparator() in fr_FR is '\u00a0' > > 2. therefore the " " between 2 and 3 AND 8 and € is replaced by '\u00a0'. > > > > the later is the issue, and the conversion fails. > > > > Any ideas ? > > > > -Matthias > > > > [1] https://issues.apache.org/jira/browse/TRINIDAD-202 > > > > -- > > Matthias Wessendorf > > > > further stuff: > > blog: http://matthiaswessendorf.wordpress.com/ > > sessions: http://www.slideshare.net/mwessendorf > > mail: matzew-at-apache-dot-org > > > > > > > > > > > > > > > > > > -- > > Matthias Wessendorf > > further stuff: > blog: http://matthiaswessendorf.wordpress.com/ > sessions: http://www.slideshare.net/mwessendorf > mail: matzew-at-apache-dot-org > -- Matthias Wessendorf further stuff: blog: http://matthiaswessendorf.wordpress.com/ sessions: http://www.slideshare.net/mwessendorf mail: matzew-at-apache-dot-org
