OK... so it's not Wicket related, it is a combination of Bootstrap + Chrome
+ HTML5. This blog post I found actually explains it quite well:
http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/

The short version is that there is a step attribute when an input's type is
number. If you don't specify a step then it defaults to 1 making decimal
values invalid. As soon as I set step="0.01" it worked like a champ (I did
that because it's a currency, but you can also set step="any").

Coming back to Wicket, since the NumberTextField component has the ability
to setMaximum & setMinimum, should it also have a setStep method? Otherwise
you're forced to use a combination of Wicket methods & HTML attributes to
control the input box.

Thoughts?

Bill-


On Mon, Mar 11, 2013 at 4:51 PM, William Speirs <[email protected]> wrote:

> I'll need to double check and get back to you, but I think it might be a
> bootstrap issue. The input box gets styled with controls to increase and
> decrease the number and that might be the issue.
>
> Thanks...
>
> Bill-
> On Mar 11, 2013 5:30 AM, "Martin Grigorov" <[email protected]> wrote:
>
>> Hi,
>>
>>
>> On Sun, Mar 10, 2013 at 9:38 PM, William Speirs <[email protected]>
>> wrote:
>>
>> > I'm trying to use a NumberTextField with a type of Double and the form
>> will
>> > only let me type in integers (or doubles that end in .0). Is this a
>> known
>> > issue? Is there a workaround?
>> >
>>
>> Can you explain more ? I don't remember having such restrictions when I
>> used NTF.
>> Which browser do you use ?
>> Can you create a plain HTML file (without using Wicket) and try to use
>> <input type="number" .../> with a double with higher precision ?
>>
>>
>> >
>> > My basic code...
>> >
>> > *Java*
>> >     private IModel<Double> doubleModel;
>> >
>> >         final NumberTextField<Double> d = new
>> NumberTextField<Double>("d",
>> > doubleModel, Double.class);
>> >
>> >         d.setMinimum(1.0d);
>> >         d.setMaximum(1000.0d);
>> >         d.setRequired(true);
>> >
>> >         form.add(d);
>> >
>> > *HTML*
>> >
>> >                   <div class="control-group">
>> >                     <label class="control-label" for="d">Double</label>
>> >                     <div class="controls">
>> >                       <input type="number" wicket:id="d"></input>
>> >                     </div>
>> >                   </div>
>> >
>> >
>> > Am I using the wrong component or HTML input type or something? Every
>> time
>> > I type in a number like 5.5 and try to submit the form I get the pop-up
>> > that say, "Invalid value."
>> >
>> > Thoughts?
>> >
>> > Thanks...
>> >
>> > Bill-
>> >
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com <http://jweekend.com/>
>>
>

Reply via email to