0

Instant true problem

asked 2014-01-30 13:16:57 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Hi In the list box, one of the column, i have the decimal box as shown.

<listcell
                            onClick="@command('onListCellClick',lineItem=p1)">
                            <decimalbox cols="25"
                                onChange="@command('doTotal')"   instant="true"
                                value="@bind(p1.postingAllowedAmt)" mold="rounded"
                                format="####.##" hflex="1" />
                        </listcell>

Problem here is when user want to type with decimal values, say for example 30.05, then after entering 30, and after entering the dot , quickly the dot disappears and whatever entered it becomes whole number like 3005.

How to correct this problem

delete flag offensive retag edit

12 Answers

Sort by ยป oldest newest most voted
1

answered 2014-01-30 13:59:27 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

Already known issue. Depends on your locale.

See here for the the discutions : http://forum.zkoss.org/question/49959/how-to-tell-to-all-decimalboxes-and-doubleboxes-in-application-to-take-dot-as-decimal-separator/

link publish delete flag offensive edit
1

answered 2014-02-13 07:37:40 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2014-02-13 07:40:12 +0800

if you check the documentation on instant="true" you can see the value is instantly sent to the server, parsed/validated and returned.

Therefore the decimal point is removed if you are not quick enough (by default 350ms). If you type the next digit within 350ms the decimal point will not be removed.

That's the side effect "instant=true", without it, the widget will wait until the input has lost focus, before sending the information to the server.

To increase the delay you can add this script to your page (see here)

<?script content="zk.afterLoad('zul.inp',function({zul.inp.InputWidget.onChangingDelay=1000;})"?>

Robert

link publish delete flag offensive edit
0

answered 2014-02-05 07:38:46 +0800

cor3000 gravatar image cor3000
6280 2 7

Hi Senthil,

Decimal box as any other NumberInputElement is locale specific. So in order to get a specific formatting use the locale like this. If you don't specify it, it will assume the server default locale. The format string will ususally be the same but the formatted output and parsed input will use locale specific group- and decimal-separators.

e.g.

<zk>
  <grid width="300px">
    <rows>
      <row>
        DE locale <decimalbox locale="de" format="#,###.##" value="2000.50"/>
      </row>
      <row>
        EN locale <decimalbox locale="en" format="#,###.##" value="2000.51"/>
      </row>
    </rows>
  </grid>
</zk>

Also see: http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html

Regards,

Robert

link publish delete flag offensive edit
0

answered 2014-02-05 21:09:00 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thanks robert. But when i remove the instant = true, every thing works fine.

link publish delete flag offensive edit
0

answered 2014-02-13 12:53:20 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thank you robert.

Even after increasing the delay, still have the same problem. For time being, i am using with onBlur event (lost focus)

link publish delete flag offensive edit

Comments

if you want to notify the server of the user typing you might just listen to the "onChanging" event on the server, this will not interrupt the user input, by formatting the value before the user has finished typing

cor3000 ( 2014-02-14 06:29:00 +0800 )edit
0

answered 2014-02-26 10:15:35 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

updated 2014-02-26 10:21:43 +0800

This is really killing me. Even though i have included the following script in the top

<?script content="zk.afterLoad('zul.inp',function({zul.inp.InputWidget.onChangingDelay=1000;})"?>

But still the following code giving me the problem

<decimalbox id="amount"
                                        cols="25" mold="rounded" format="#,###.##" hflex="1"
                                        name="fee" readonly="@load(vm.makeAsReadOnly)"
                                        value="@bind(fx.amount)" />

Here is the problem

  1. Type 929.
  2. Do alt tab in windows and look at the some other document
  3. Then come back, you can see that, dot has been removed.
link publish delete flag offensive edit
0

answered 2014-02-26 10:24:43 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Wow, even in zk demo itself having the same problem

ZK Demo

In the weight box, type 45. and do alt tab in windows and then come back, you can see dot has been removed.

link publish delete flag offensive edit

Comments

when typing ALT-TAB the component loses its focus and applies the format. I don't see a problem there. the "onChangingDelay=1000" will only affect the delay while typing and not the formatting onChange (after focus lost). How do you expect the value to be updated if not onBlur ??

cor3000 ( 2014-02-26 14:09:57 +0800 )edit
0

answered 2014-02-26 14:30:24 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2623 3 8
http://emrpms.blogspot.in...

Thank you Robert. But it is giving major problem for me. Current application is accounting system application, where user will be entering the values as per the statement received from the bank as pdf. So they will open the PDF and my application, use alt tab to navigate between two windows to enter the values.

link publish delete flag offensive edit

Comments

it seems difficult to give a simple answer about this: maybe you can describe the exact sequence about when the format should be applied and when not, maybe there is a way to distinguish between the steps and prevent the formatting in certain conditions

cor3000 ( 2014-02-26 15:02:35 +0800 )edit
0

answered 2014-02-27 07:11:34 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2014-02-27 07:18:56 +0800

Hi Senthil,

You can handle number formatting yourself to format the number as your need (e.g., always keep '.' and display error message if a number ends with '.' while save button clicked), for more information please refer to the related article at my blog: ZK Decimalbox Support Scientific Notation

You can also view the source code directly.

  • Probably buggy, need to test it carefully.
link publish delete flag offensive edit
0

answered 2014-02-27 09:22:12 +0800

neillee gravatar image neillee flag of Taiwan
1692 1 5
https://plus.google.com/u...

The character '#' in the format string "####.##" means that the non-significant zero digits would not be displayed. When the focus is lost (e.g. tab to another input widget or switch to another browser tab), decimalbox would think the "entering value phase" has finished, and would apply the format. If the value is "45." at this moment, applying the format would remove the decimal point since the fractional part is zero.

The following is a way to solve the "value entering" interruption issue.

  1. Use a textbox to collect partial input
  2. Have a button to confirm the input
  3. Only after confirmation would the value be copied to the real decimalbox, and the format applied.

See zkfiddle example

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2014-01-30 13:16:57 +0800

Seen: 91 times

Last updated: Feb 13 '15

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