You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Ömer Başar (JIRA)" <ji...@apache.org> on 2007/09/13 08:32:35 UTC

[jira] Created: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

In Turkish locale "TR" double values are multiplied by ten on every page load
-----------------------------------------------------------------------------

                 Key: WW-2176
                 URL: https://issues.apache.org/struts/browse/WW-2176
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.0.9, 2.0.8, 2.0.7, 2.0.6, 2.0.5, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.1.0
         Environment: Windows XP, java 5 and java 6 using appfuse
            Reporter: Ömer Başar
            Priority: Blocker


The steps to get the error.

1 - Change your locale to "TR" (Turkish)
2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
3 - Fill only the salary field with "10"
4 - Press Save, it shows the required fields and makes the salary field "10.0"
5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
6 - Alter the salary field. Make it "100,0" (change dot with comma)
7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.

Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 

Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Gleison Caetano (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42577 ] 

gleisoncs edited comment on WW-2176 at 11/5/07 3:58 PM:
--------------------------------------------------------------

We should to turn in pattern inside entity or inside action for example down. I solved this problem like this:

1) in entity:
...
	public Double getVlCust() {
		return vlCust;
	}

	public String getVlCustFormatted() {
		return Utils.convertDoubleToString(vlCust);
	}
...

2) in some class util like Utils:
...
	public static String convertDoubleToString(Double value) {
		return (String) new CurrencyConverter().convert(String.class, value);
	}
...

3) in jsp form:
<s:textfield key="produto.vlCust" value="%{produto.vlCustFormatted}" required="false" cssClass="text medium"/>

4) in jsp list:
<display:column property="vlCustFormatted" sortable="true" titleKey="produto.vlCust"/>

      was (Author: gleisoncs):
    Should we turn pattern in entity or in action for example down. I solved this problem like this:

1) in entity:
...
	public Double getVlCust() {
		return vlCust;
	}

	public String getVlCustFormatted() {
		return Utils.convertDoubleToString(vlCust);
	}
...

2) in some class util like Utils:
...
	public static String convertDoubleToString(Double value) {
		return (String) new CurrencyConverter().convert(String.class, value);
	}
...

3) in jsp form:
<s:textfield key="produto.vlCust" value="%{produto.vlCustFormatted}" required="false" cssClass="text medium"/>

4) in jsp list:
<display:column property="vlCustFormatted" sortable="true" titleKey="produto.vlCust"/>
  
> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.1.2
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Gleison Caetano (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42577 ] 

Gleison Caetano commented on WW-2176:
-------------------------------------

Should we turn pattern in entity or in action for example down. I solved this problem like this:

1) in entity:
...
	public Double getVlCust() {
		return vlCust;
	}

	public String getVlCustFormatted() {
		return Utils.convertDoubleToString(vlCust);
	}
...

2) in some class util like Utils:
...
	public static String convertDoubleToString(Double value) {
		return (String) new CurrencyConverter().convert(String.class, value);
	}
...

3) in jsp form:
<s:textfield key="produto.vlCust" value="%{produto.vlCustFormatted}" required="false" cssClass="text medium"/>

4) in jsp list:
<display:column property="vlCustFormatted" sortable="true" titleKey="produto.vlCust"/>

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.1.2
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Ömer Başar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ömer Başar updated WW-2176:
---------------------------

    Attachment: struts2locale_error.avi

Here is the video file giving this error

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6 using appfuse
>            Reporter: Ömer Başar
>            Priority: Blocker
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dave Newton updated WW-2176:
----------------------------

    Comment: was deleted

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Critical
>             Fix For: 2.2.x
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown updated WW-2176:
--------------------------

    Fix Version/s:     (was: 2.1.3)
                   2.2.x

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Critical
>             Fix For: 2.2.x
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Sebastian (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42766 ] 

Sebastian commented on WW-2176:
-------------------------------

I am writing a German localized application and encountered the same issue. I took me unneccssary hours of time to localize the problem and fix it with a workaround (thanks, Amaury, now I also use the text input tag).

I agree that parsing using locale and formatting without is not an intuitive behavior and is bad design.




> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.1.2
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2176:
-----------------------------

    Fix Version/s: 2.0.11

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.0.11
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Ömer Başar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ömer Başar updated WW-2176:
---------------------------

    Environment: Windows XP, java 5 and java 6  (was: Windows XP, java 5 and java 6 using appfuse)

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Amaury Crickx (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42289 ] 

Amaury Crickx commented on WW-2176:
-----------------------------------

Same is true for quite a few other European locales (French, Danish, ...)

Due to some nasty feature of the java platform, parsing 10,0 with English locale succeeds with a value of 100. 
So what we have here is when your locale has '.' as thousand separator, your number becomes 100.
The real problem is actually that the number is not formatted back to string using your locale.

This issue is related to known issues in xwork : 
http://jira.opensymphony.com/browse/XW-490 : XWorkBasicConverter.doConvertToString(...) ignores Locale for instances of Number
http://jira.opensymphony.com/browse/XW-543 : XWorkBasicConverter broken with primitives

XW-490 comments state it clear : locale is used when parsing from String to Float or Double objects (not primitives) but NOT when formatting from Double/Float to String
Fixing the problem brought nasty side effect like url params being formatted with the thousand separator : ?id=1,234 instead of ?id=1234
Bringing locale specific formatting into bookmarkable urls is IMHO not a good idea. 
This bug has been rescheduled to xwork 2.1 with a possible outcome of won't fix , let the view handle this.
Personally, I'd say that parsing using locale and formatting without is not an intuitive behavior either. 
Actually, it will be difficult to document without giving a feeling of code smell ;-)

I also mentioned issue XW-543 because it appears that for the moment primitive numbers are not parsed using the same code in XWorkBasicConverter but rather delegated to OGNL which doesn't handle locale at all...


Back to this bug : there is a way to fix this, but I wouldn't call it elegant.

In the showCase app, there is a resource bundle called globalMessages.properties where the following line should be added 
(no need to add it to all locales : I don't add text and the formatting will use the current locale):
number={0,number}

Then modify editEmployee.jsp and replace the line
<s:textfield label="Salary" name="currentEmployee.salary"/>

with 

<s:text name="number" var="formattedSalary"><s:param value="currentEmployee.salary"/></s:text>
<s:textfield label="Salary" name="currentEmployee.salary" value="%{formattedSalary}"/>

Note that depending on your version you may have to use "id" instead of "var" as text tag attribute.
Which basically means: 

1. get the salary Float object from current employee and have it added to a List of arguments, 
search resource bundles to find the key 'number', 
parse the given message value and replace parameters with converted/formatted value
push result to formattedSalary on the stack

2. when displaying textfield, use the stack value.

It works but... I wished I could specify a formatter directly into the textfield tag or have a FormattedTextField tag (à la Swing) or ... anything that could ease the pain of localized numbers
I'm wishing to help if I can...

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.0.12
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Amaury Crickx (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42370 ] 

Amaury Crickx commented on WW-2176:
-----------------------------------

Yes, you're right.

But I'd like to mention I went down the road of adding methods to my base action and found my class bloated with all kinds of things that really didn't belong there...
IMHO, OGNL is really great but can bring bad habits...

When the business requirements changed and changed again while the presentation still had to remain approximatively the same and I realized I should really have used some kind of presentation model specific to my web app. So I refactored it out injecting the locale into that view model and suddenly these view objects became the perfect place to place for the required formatting (Sometimes using static helper methods in a common util class). 

I also use specific form classes when it comes to updating the model.

This brings lots of boiler plate code (get/set mostly delegating to the wrapped object for the views, form class hierarchy/relationships that often mimics the business model hierarchy/relationships)
But in the end the flexibility gained is well worth the price.

In the end, nothing really astonishing I think: I just placed my presentation logic into my presentation model instead of the controller. 
 

Yet: I'd say IMHO parsing using locale and formatting without is not an intuitive behavior for a framework like Struts. 

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.0.12
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Rene Gielen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rene Gielen resolved WW-2176.
-----------------------------

       Resolution: Duplicate
    Fix Version/s:     (was: 2.2.x)
                   2.1.7
         Assignee: Rene Gielen

Fixed by WW-3027 and WW-3028.

Nevertheless, we have to think about handier solutions

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Assignee: Rene Gielen
>            Priority: Critical
>             Fix For: 2.1.7
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Jørgen Larsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42365 ] 

Jørgen Larsen commented on WW-2176:
-----------------------------------

Norwegians are having the same experience.

I don't think the above solution will work for <s:selects, so my fix on this problem was to add an helper method in my BaseAction (all other actions extends this action).
I.e for doubles I added BaseAction.formatDouble method that uses the default locale. So my <s:select ended up like this:

<s:select 
   tooltip="Choose discount"
   label="Discount"
   list="contractDiscounts"
   name="contract.discountFactor"
   listKey="formatDouble(discountFactor)"
   listValue="description"
   emptyOption="false"
   headerKey="-1"
   headerValue="-- No discount --"/>

This seems to solve my problem regarding doubles and dates "roundtrip" from object to form and back again

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.0.12
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2176:
-----------------------------

    Fix Version/s:     (was: 2.0.11)
                   2.0.12

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Blocker
>             Fix For: 2.0.12
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown updated WW-2176:
--------------------------

         Priority: Critical  (was: Blocker)
    Fix Version/s:     (was: 2.1.2)
                   2.1.3

I agree this is a serious XWork issue and when I last talked to Rainer, he planned to overhaul this area to fix the root issues. 

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Critical
>             Fix For: 2.1.3
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2176) In Turkish locale "TR" double values are multiplied by ten on every page load

Posted by "Noel Hernández (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45457#action_45457 ] 

Noel Hernández commented on WW-2176:
------------------------------------

This kind of issue is normal for applications written by people that doesn't know what a locale is.
Struts2 can't be taken seriously, looking at the workarounds and the comments.
I don't know if the architectural decisions are very poor or the Framework are too BETA for the real world.
I quit

> In Turkish locale "TR" double values are multiplied by ten on every page load
> -----------------------------------------------------------------------------
>
>                 Key: WW-2176
>                 URL: https://issues.apache.org/struts/browse/WW-2176
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.1.0
>         Environment: Windows XP, java 5 and java 6
>            Reporter: Ömer Başar
>            Priority: Critical
>             Fix For: 2.2.x
>
>         Attachments: struts2locale_error.avi
>
>
> The steps to get the error.
> 1 - Change your locale to "TR" (Turkish)
> 2 - go to edit employee page on showcase application - http://www.planetstruts.org/struts2-showcase/employee/save.action
> 3 - Fill only the salary field with "10"
> 4 - Press Save, it shows the required fields and makes the salary field "10.0"
> 5 - Press Save again without editing anything, it gives the error for required fields and makes the salary field "100.0"
> 6 - Alter the salary field. Make it "100,0" (change dot with comma)
> 7 - press save, here it is not multiplied by 10, but it changes the salary field value from "100,0" to "100.0" again.
> Here is the problem. In Turkish(TR) locale the decimal separator is "comma", not "dot". So it doesn't convert them according to the TR locale which is the locale of my browser. When I press save at the 4th and 5th steps it should write "10,0" using the locale of the browser. 
> Note : When I change my locale to "EN" everything works fine. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.