You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org> on 2007/12/03 19:17:43 UTC
[jira] Created: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
France Locale and NumberConverter doesn't work well with currency strings
-------------------------------------------------------------------------
Key: MYFACES-1782
URL: https://issues.apache.org/jira/browse/MYFACES-1782
Project: MyFaces Core
Issue Type: Bug
Components: JSR-252
Affects Versions: 1.2.0
Reporter: Matthias Weßendorf
Assignee: Matthias Weßendorf
This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
protected void setUp() throws Exception
{
super.setUp();
mock = new NumberConverter();
mock.setLocale(Locale.FRANCE);
FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
}
public void testFranceLocale()
{
UIInput input = new UIInput();
mock.setType("currency");
Number number = (Number)
mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
€");
assertNotNull(number);
}
the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
Posted by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12547994 ]
Matthias Weßendorf commented on MYFACES-1782:
---------------------------------------------
In the original version of NumberConverter a currency string (for some Locale's like fr_FR or fi_FI) can't be convertered, when value submitted via web-browser
(like "12 345,68 €").
The Java API of NumberFormat is expecting a nb space inside the "numbers" as the grouping separator.
A String like "12\u00a0345,68 €" would be OK.
The fix is to replace the grouping_separator, when the grouping_separator is a nb-space ('\u00a0'), with a regular blank (" ").
So a String like "12 345,68 €" would be OK as well.
Now... a String like ("12\u00a0345,68 €") would fail (which is only the case if not edited etc).
In case the format.parse() is really failing... we re-replace the grouping_separator and call format.parse() again.
The patch also contains two tests, which proof the behavior.
Attaching as a patch, to check with the TCK.
> France Locale and NumberConverter doesn't work well with currency strings
> -------------------------------------------------------------------------
>
> Key: MYFACES-1782
> URL: https://issues.apache.org/jira/browse/MYFACES-1782
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-252
> Affects Versions: 1.2.0
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Attachments: MYFACES-1782.patch
>
>
> This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
> protected void setUp() throws Exception
> {
> super.setUp();
> mock = new NumberConverter();
> mock.setLocale(Locale.FRANCE);
> FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> }
> public void testFranceLocale()
> {
> UIInput input = new UIInput();
> mock.setType("currency");
> Number number = (Number)
> mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> €");
> assertNotNull(number);
> }
> the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
Posted by "Martin Marinschek (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12547999 ]
Martin Marinschek commented on MYFACES-1782:
--------------------------------------------
So you're saying the default grouping separator for the fr_FR locale is \u00a?
regards,
Martin
> France Locale and NumberConverter doesn't work well with currency strings
> -------------------------------------------------------------------------
>
> Key: MYFACES-1782
> URL: https://issues.apache.org/jira/browse/MYFACES-1782
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-252
> Affects Versions: 1.2.0
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Attachments: MYFACES-1782.patch
>
>
> This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
> protected void setUp() throws Exception
> {
> super.setUp();
> mock = new NumberConverter();
> mock.setLocale(Locale.FRANCE);
> FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> }
> public void testFranceLocale()
> {
> UIInput input = new UIInput();
> mock.setType("currency");
> Number number = (Number)
> mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> €");
> assertNotNull(number);
> }
> the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
Posted by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12548001 ]
Matthias Weßendorf commented on MYFACES-1782:
---------------------------------------------
It is \u00a0, but yes that's right.
> France Locale and NumberConverter doesn't work well with currency strings
> -------------------------------------------------------------------------
>
> Key: MYFACES-1782
> URL: https://issues.apache.org/jira/browse/MYFACES-1782
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-252
> Affects Versions: 1.2.0
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Attachments: MYFACES-1782.patch
>
>
> This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
> protected void setUp() throws Exception
> {
> super.setUp();
> mock = new NumberConverter();
> mock.setLocale(Locale.FRANCE);
> FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> }
> public void testFranceLocale()
> {
> UIInput input = new UIInput();
> mock.setType("currency");
> Number number = (Number)
> mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> €");
> assertNotNull(number);
> }
> the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
Posted by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12548007 ]
Matthias Weßendorf commented on MYFACES-1782:
---------------------------------------------
Well... it is not particular fr_FR.
That is true for all Locale's that have nb-space as groupingSeparator (as fi_FI does as well).
In Trinidad NumberConverter we already deal with this...by hard-coded replaceing a regular blank ' ' with a nb-space '\u00a0'
That causes a "currency string", like "12\u00a0345,68\u00a0€".
Which obviously has to fail :-)
The "problem" is, that a currency String for those Locale's contains both,
breaking and non-breaking spaces.
The Trinidad "work around" was added because of the mentioned Java API bug, but the work around is not complete, but this fix completes it.
> France Locale and NumberConverter doesn't work well with currency strings
> -------------------------------------------------------------------------
>
> Key: MYFACES-1782
> URL: https://issues.apache.org/jira/browse/MYFACES-1782
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-252
> Affects Versions: 1.2.0
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Attachments: MYFACES-1782.patch
>
>
> This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
> protected void setUp() throws Exception
> {
> super.setUp();
> mock = new NumberConverter();
> mock.setLocale(Locale.FRANCE);
> FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> }
> public void testFranceLocale()
> {
> UIInput input = new UIInput();
> mock.setType("currency");
> Number number = (Number)
> mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> €");
> assertNotNull(number);
> }
> the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MYFACES-1782) France Locale and NumberConverter
doesn't work well with currency strings
Posted by "Matthias Weßendorf (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/MYFACES-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthias Weßendorf resolved MYFACES-1782.
-----------------------------------------
Resolution: Fixed
Fix Version/s: 1.2.1-SNAPSHOT
> France Locale and NumberConverter doesn't work well with currency strings
> -------------------------------------------------------------------------
>
> Key: MYFACES-1782
> URL: https://issues.apache.org/jira/browse/MYFACES-1782
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-252
> Affects Versions: 1.2.0
> Reporter: Matthias Weßendorf
> Assignee: Matthias Weßendorf
> Fix For: 1.2.1-SNAPSHOT
>
> Attachments: MYFACES-1782.patch
>
>
> This test-case shows, that there is a failure inside the standard NumberConverter (MyFaces):
> protected void setUp() throws Exception
> {
> super.setUp();
> mock = new NumberConverter();
> mock.setLocale(Locale.FRANCE);
> FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMANY);
> }
> public void testFranceLocale()
> {
> UIInput input = new UIInput();
> mock.setType("currency");
> Number number = (Number)
> mock.getAsObject(FacesContext.getCurrentInstance(), input, "12 345,68
> €");
> assertNotNull(number);
> }
> the grouping_sep should be a nb-space...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.