Required Information

Version(s) of Ext GWT
Ext GWT 3.0.4 (and probably all of 3.x)

Browser versions and OS
(and desktop environment, if applicable)
  • Not tested w/ IE, but checked on:
  • Chrome 24, OS X 10.8
  • Chrome 24, Ubuntu 11.10, GNOME
  • Firefox 18, Ubuntu 11.10, GNOME

Virtual Machine

Once set, DateField.setMinValue(Date) and DateField.setMaxValue(Date) do not allow the values to be reset by passing null as a parameter. Rather they throw an NPE because underneath it attempts to create either a min/max date validator with the null value or set the min/max date on the existing, internal min/max validator w/ the null value.

Run mode

Steps to reproduce the problem
  1. </i>
  2. Start running in development mode in Eclipse
  3. Open app in browser
  4. Construct a DateField object, say "dateField"
  5. call dateField.setMaxValue(null) and/or dateField.setMinValue(null), results in an NPE.

Expected result
No error, expect it to reset the underlying min/max dates

Actual result
An NPE is thrown

Test case
public class DateFieldTest implements EntryPoint
   public void onModuleLoad()
      final DateField dateField = new DateField();
      FieldLabel fl = new FieldLabel(dateField, "Start");
      CssFloatLayoutContainer cflc = new CssFloatLayoutContainer();
      cflc.add(new TextButton("Set Null Min", new SelectEvent.SelectHandler()
         public void onSelect(SelectEvent event)
            dateField.setMinValue(null); // throws NPE
      cflc.add(new TextButton("Set Null Max", new SelectEvent.SelectHandler()
         public void onSelect(SelectEvent event)
            dateField.setMaxValue(null); // throws NPE

      ContentPanel cp = new ContentPanel();
      cp.setPixelSize(600, 200);

Helpful Information

Debugging already done
  • The problem is that the underlying code constructs a min and max date validator and uses the date parameter value unchecked whereas the very next if block checks that value for null before attempting to set that value on the validator that was just constructed.

Possible fix
  • The proper behavior is probably to unwire the validator if the parameter is null and perform any other bookkeeping (e.g., talking to the date picker).