Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTGWT-2824
in
3.0.5.
-
DateField does not allow unsetting the max and min date values
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
No
Description
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
both
Steps to reproduce the problem
- </i>
- Start running in development mode in Eclipse
- Open app in browser
- Construct a DateField object, say "dateField"
- 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
Code:
public class DateFieldTest implements EntryPoint
{
@Override
public void onModuleLoad()
{
final DateField dateField = new DateField();
FieldLabel fl = new FieldLabel(dateField, "Start");
CssFloatLayoutContainer cflc = new CssFloatLayoutContainer();
cflc.add(fl);
cflc.add(new TextButton("Set Null Min", new SelectEvent.SelectHandler()
{
@Override
public void onSelect(SelectEvent event)
{
dateField.setMinValue(null); // throws NPE
}
}));
cflc.add(new TextButton("Set Null Max", new SelectEvent.SelectHandler()
{
@Override
public void onSelect(SelectEvent event)
{
dateField.setMaxValue(null); // throws NPE
}
}));
ContentPanel cp = new ContentPanel();
cp.setPixelSize(600, 200);
cp.setWidget(cflc);
RootPanel.get().add(cp);
}
}
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).
-
Thanks for the report! I have opened a bug in our bug tracker.
-
Sencha - Support Team
This issue has been fixed and is available in SVN. It will be available when 3.0.5 is released.
Brandon