# How to tell to all decimalboxes and doubleboxes in application to take dot as decimal separator?

Arsen
383 4

Subject is the question.

delete retag edit

## 8 Replies

9393 3 7 16
http://www.oxitec.de/

I mean the right place is the lang-addon.xml

<language-addon>

.  .  .

<!-- ====================================================== -->
<!--     Define properties for commonly used components     -->
<!-- ====================================================== -->
<component>
<component-name>decimalbox</component-name>
<extends>decimalbox</extends>
<property>
<property-name>format</property-name>
<property-value>#,##0.00</property-value>
</property>
</component>

</language-addon>

zk.xml


.   .   .

<!-- ========================================================== -->
<!--            Path to the character set and sizes             -->
<!--                  Zkoss configuration file                  -->
<!--           Custom components are declared here              -->
<!-- ========================================================== -->
<language-config>
</language-config>



best
Stephan

Arsen
383 4

Thanks, Stephan.
But here is the strange thing with attribute "format"
decimailbox without specified format. It takes only comma as decimal separator, but always shows validation error message, like it wants me to write dot instead of comma. But it does not allow me to write dot - only comma. Regardless to validation errror message, this decimal box loads correct value to binded property, ex:

<decimalbox value="@{myController.decimalValue}"/>


If I specify value "4,45" then validation message showed but myController.decimalValue become 4.45.
Now decimal box with format
<decimalbox  format="#,##0.00" value="@{myController.decimalValue}"/>


This one also takes only comma as decimal separator, but not dot. But this one does not show validation error message.

It seems like some kind of bug.

9393 3 7 16
http://www.oxitec.de/

Hmmm, i do not believe that's a bug. Seems that's a normal behaviour from SUN's DecimalFormatter class.

I remember that for a few months here in the forum are a thread about that. Someone means that for such a purpose you must rewritten the decimalbox.
Have a look on searching the thread.

 * @see          <a href="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html">Java Tutorial</a>
* @see          NumberFormat
* @see          DecimalFormatSymbols
* @see          ParsePosition
* @version      1.88 06/26/06
* @author       Mark Davis
* @author       Alan Liu
*/
public class DecimalFormat extends NumberFormat {


best
Stephan

Arsen
383 4

Hi, Stephan.
I think the bug is when decimal box allows only comma as decimal separator, but alerts with validattion error message if I specify comma-separated float value. Ths is first case in my previous post (without format specified). This happens only in ZK 5.0.3 , but with 3.6 issue is not reproduced.

Matze2
773 7

I had also bad experiences with decimalbox without format. The behavior seems unpredictable to me.
I can only recommend to give a format attribute.

Regarding the decimal separator character: as far as I know, it depends on the locale and not on the given decimal format.
if you switch your browser to English ("en-us", for example), then you should get a decimal point.

Arsen
383 4

Thnaks, Matze.

SimonPai
1696 1

Hi all,

I second Stephan's and Matze's comment. Using comma as decimal separator is defined by Sun's spec.
In addition, you can try to use setPreferredLocale to set your locale to English.

Regards,
Simon

juazisco
3

hi, i need to change decimal separated in the zk spreadsheet, this is my big problem, i don't know any method :(

[hide preview]