0

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

asked 2010-07-01 14:17:18 +0800

Arsen gravatar image Arsen
383 4

Subject is the question.

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2010-07-01 14:31:11 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-07-01 14:32:08 +0800

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

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>
		<addon-uri>/WEB-INF/lang-addon.xml</addon-uri>
	</language-config>

best
Stephan

link publish delete flag offensive edit

answered 2010-07-02 01:31:33 +0800

Arsen gravatar image 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.

link publish delete flag offensive edit

answered 2010-07-02 04:32:16 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-07-02 04:33:09 +0800

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

link publish delete flag offensive edit

answered 2010-07-03 07:02:14 +0800

Arsen gravatar image 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.

link publish delete flag offensive edit

answered 2010-07-03 07:58:53 +0800

Matze2 gravatar image 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.

link publish delete flag offensive edit

answered 2010-07-03 08:03:22 +0800

Arsen gravatar image Arsen
383 4

Thnaks, Matze.

link publish delete flag offensive edit

answered 2010-07-07 05:36:31 +0800

SimonPai gravatar image 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

link publish delete flag offensive edit

answered 2011-11-18 14:49:26 +0800

juazisco gravatar image juazisco
3

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-07-01 14:17:18 +0800

Seen: 939 times

Last updated: Nov 18 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More