Menu

#2002 Problem with dynamic setting of format pattern

5.0.1
closed-fixed
nobody
5
2010-05-10
2010-05-07
Anonymous
No

Wrong (client side?!) behavior of decimalboxes when the formatting pattern is set dynamically.
This can cause lots of problems when the Locale has a different decimal separator that "." .

here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./window"?>
<window title="Test Eventi" id="window">
<zscript><![CDATA[
//prepare the example person object
java.math.BigDecimal numberValue = new java.math.BigDecimal(128990.21);
class Test{
String pattern;
java.math.BigDecimal value;
public Test(java.math.BigDecimal value,String pattern){
this.value = value;
this.pattern = pattern;
}

public String getPattern(){return pattern;}
public java.math.BigDecimal getValue(){return value;}
public void setPattern(String pattern){this.pattern = pattern;}
public void setValue(java.math.BigDecimal value){this.value=value;}
}
]]>
</zscript>
<button label="Test Dynamic Decimal Format Pattern">
<attribute name="onClick">
<![CDATA[
window.getAttribute("binder").bindBean("test",new Test(new java.math.BigDecimal(154.233),"#,###.00"));
window.getAttribute("binder").loadComponent(box);
]]>
</attribute>
</button>
<decimalbox id="box" format="@{test.pattern}" value="@{test.value}" />
</window>

With an English locale, after the first click on the button the decimalbox should show "154.23" while it shows
"154.23300000000000409272615797817707061767578125".
In order to get the decimalbox to show the proper string, an onChange event have to be triggered.

With and Italian,German or French locale, after an onChange event, ""154.23300000000000409272615797817707061767578125"
become "15.423.300.000.000.000.409.272.615.797.817.707.061.767.578.125,00" instead of "154,23". Quite a big difference.

Discussion

  • Henri Chen

    Henri Chen - 2010-05-10

    Fixed since May 10, 2010.

     
  • Henri Chen

    Henri Chen - 2010-05-10
    • labels: 982602 --> Components
    • milestone: 598023 --> 5.0.1
    • summary: Problem with dynamic setting of decimalbox format pattern --> Problem with dynamic setting of format pattern
    • status: open --> closed-fixed
     

Log in to post a comment.