PDA

View Full Version : [FIXED] TimeField.setRawValue() issue



liukaipeng
4 Sep 2008, 9:05 PM
With the following code, I encounter a NullPointerException.

TimeField field = new TimeField();
field.setFormat(DateTimeFormat.getFormat("HH:mm"));
field.setRawValue("10:00");

FormPanel formPanel = new FormPanel();
formPanel.add(field);
......

Exception:
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.form.ComboBox.setRawValue(ComboBox.java:711)
at com.linkup.reportal.client.pages.ReportFormPage.createFormPanel(ReportFormPage.java:137)
at com.linkup.reportal.client.pages.ReportFormPage.onRender(ReportFormPage.java:107)
at com.linkup.reportal.client.pages.ReportFormBorderPage.onRender(ReportFormBorderPage.java:24)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:781)
......

I find that in the combobox's setRawValue(), there's no check against rendered like other Field implementation, and getInputEl() returns null. Is this the matter, or I've made some mistakes?

darrellmeyer
9 Sep 2008, 9:33 AM
In almost all situations, you should not need to call setRawValue as it bypasses important logic withing the fields. I went ahead and added the render check to ComboBox to avoid the exception.