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

DatePicker fail with "firstDate is undefined" when an out of range date is written in the textfield

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.8
    • 1.4.11, 1.5-M2.1
    • wicket-datetime
    • None

    Description

      When a DatePicker is configured with a range (mindate and maxdate) and the user enter a date out of the range in the textfield and click on the datepicker icon there is an javascript error and the calendar don't pop up.

      There is a "firstDate is undefined" in this javascript method (line with widget.cfg.setProperty)
      Wicket.DateTime.showCalendar = function(widget, date, datePattern) {
      if (date) {
      date = Wicket.DateTime.parseDate(datePattern, date);
      if (!isNaN(date))

      { widget.select(date); firstDate = widget.getSelectedDates()[0]; widget.cfg.setProperty("pagedate", (firstDate.getMonth() + 1) + "/" + firstDate.getFullYear()); widget.render(); }

      }
      widget.show();
      }

      To fix the issue you can test the firstDate value after getSelectedDates call. YUI Calendar return undefined value when the selected date is out of the range.

      Attachments

        1. patch.txt
          0.8 kB
          Michel DAVID

        Activity

          People

            ivaynberg Igor Vaynberg
            mimah35 Michel DAVID
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: