-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Having a doublebox without informing the format, value of "2.0" appeared as "20".
Adding the format="0.#" solved the issue.
Browser and Win 7 OS locale to en_US.
I'm not sure if this is a bug, but I sure expected that my 2.0 value didn't show up as 20 (lost a lot of time thinking it as 20 and the error was in the back end calculations...)
To be honest: I don't really trust doublebox and decimalbox.
At first, it is not clear for me why two components for same purpose - entering a float - are needed.
Second, on the client side there should not be too much difference in the handling, but the Javascript code of Decimalbox and Doublebox looks very different.
Third, without a "format" attribute, the behavior of both components is sometimes very surprising.
In my projects, I use only decimalbox together with format attribute. Even more, I patched decimalbox to not accept the grouping point character, which caused lots of confusion at our users.
By the way, this could explain why 2.0 = 20 in your case, if "." was interpreted as grouping point character.
Hope this helps.
Hi matze,
No, it was not the grouping point. Because when I inputted "2.5" it showed "2.5" correctly, when I inputted "2" it showed "20", in en_US locale the grouping point is ",".
Also, this happens when setting the doubleboxes from server side. Just inputting the values from keyboard works nice.
Now, another issue that took me a while to think "hey, might be just a doubleblex issue..."
I have two doubleboxes, when one changes, the other way may, or may not change. This is done on server side, which works.
Now I'm moving this logic to client side, which is quite simple, but with doublebox just don't work, the value is not updated at server side. Replacing doublebox with intbox works as expected.
With more testing, I got the conclusion that if you use doublebox, to support floating point values, you HAVE to use the decimal separator, otherwise things will go wrong.
Here is an exemple. Input 1 on the kbd, then click on the button. The value on server side is null. Now input "1.5", then click on the btn, then it works. I'm pretty confident that this is a bug, right?
<zk xmlns:w="http://www.zkoss.org/2005/zk/client"> <doublebox id="from" w:onChange="changeValue(this);" format="0.#"/> <doublebox id="to" format="0.#"/> <button label="Test to on server side" onClick="alert(to.getValue())"/> <script> function changeValue(cmp) { var to = cmp.$f('to'); to.setValue(cmp.getValue()); to.smartUpdate('value', cmp.getValue()); } </script> </zk>
issue for the client side programming here
I saw some commits today for Longbox and Doublebox. I am happy to see, that the grouping character got removed from the list of allowed keys.
But why are the same changes not applied to Decimalbox? This makes the behavioral differences between Decimalbox and Doublebox get bigger and bigger.
Asked: 2010-07-24 12:40:34 +0800
Seen: 621 times
Last updated: Jul 29 '10