0

Doublebox eating the decimal point

asked 2010-07-24 12:40:34 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

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...)

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-07-24 16:53:46 +0800

Matze2 gravatar image Matze2
773 7

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.

link publish delete flag offensive edit

answered 2010-07-26 16:25:33 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

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>

link publish delete flag offensive edit

answered 2010-07-27 07:28:43 +0800

madruga0315 gravatar image madruga0315 flag of Brazil
937 2 12

issue for the client side programming here

link publish delete flag offensive edit

answered 2010-07-29 02:23:16 +0800

Matze2 gravatar image Matze2
773 7

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.

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-24 12:40:34 +0800

Seen: 621 times

Last updated: Jul 29 '10

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