Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4584

NumberTextField does not have default minimum and maximum

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.6
    • 1.5.8, 6.0.0-beta3
    • wicket
    • None

    Description

      Javadoc of NumberTextField says:

      A TextField for HTML5 <input> with type number.
      Automatically validates the input against the configured min and max attributes. If any of them is null then Double.MIN_VALUE and Double.MAX_VALUE are used respectfully. Note: FormComponent.setType(Class) must be called explicitly!

      It is not true. We have constructor which sets them to null:

      public NumberTextField(String id, IModel<N> model, Class<N> type)

      { super(id, model, type); validator = null; minimum = null; maximum = null; }

      and if I don't set them manually, in case of error nulls go to RangeValidator (line 84-85:

      error.setVariable("minimum", min);
      error.setVariable("maximum", max);

      causing:
      java.lang.IllegalArgumentException: Argument 'value' may not be null.

      Nevertheless, I think reflection API should be used to determine if given Number has MAX_VALUE/MIN_VALUE and this one should be used. In other case I think it is ok to use Double.MAX_VALUE/MIN_VALUE.

      or maybe you have another ideas?

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            apierzch Adam PierzchaƂa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: