PDA

View Full Version : [FIXED] NullPointer in EditorGrid



fother
25 Mar 2009, 8:10 AM
CellEditor override postProcessValue, for example..

if user type "1" and press enter show one message and the value of the field receveid "1A", buf if user type "2" or more than "2" do nothing... the value of the field would be null, but if I return null to postProcessValue return NullPointer in EditorGrid.java:246

sven
25 Mar 2009, 8:19 AM
Example code is missing.

fother
25 Mar 2009, 8:36 AM
in the column Price type 7 and press Enter - ok
in the column Price delete the number 7 and press enter - ok (value == null)
in the column Price type 5 and press Enter - return NullPointer

the problem appears when you type on value and need return null..

code example


public void onModuleLoad() {

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Common Name");
column.setWidth(220);

TextField<String> text = new TextField<String>();
text.setAllowBlank(false);
text.setAutoValidate(true);
column.setEditor(new CellEditor(text));
configs.add(column);

final SimpleComboBox<String> combo = new SimpleComboBox<String>();
combo.setTriggerAction(TriggerAction.ALL);
combo.add("Shade");
combo.add("Mostly Shady");
combo.add("Sun or Shade");
combo.add("Mostly Sunny");
combo.add("Sunny");

column = new ColumnConfig();
column.setId("light");
column.setHeader("Light");
column.setWidth(130);
configs.add(column);

CellEditor editor = new CellEditor(new NumberField()) {
@Override
public Object postProcessValue(Object value) {

if (value != null) {
Number number = (Number) value;

if (number.intValue() == 5) {
return null;
} else {
return super.postProcessValue(value);
}
} else {
return null;
}

}
};

column = new ColumnConfig();
column.setId("price");
column.setHeader("Price");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(70);
column.setNumberFormat(NumberFormat.getCurrencyFormat());
column.setEditor(editor);

configs.add(column);

DateField dateField = new DateField();
dateField.getPropertyEditor().setFormat(DateTimeFormat.getFormat("MM/dd/y"));

column = new ColumnConfig();
column.setId("available");
column.setHeader("Available");
column.setWidth(95);
column.setEditor(new CellEditor(dateField));
column.setDateTimeFormat(DateTimeFormat.getMediumDateFormat());
configs.add(column);

CheckColumnConfig checkColumn = new CheckColumnConfig("indoor", "Indoor?", 55);
configs.add(checkColumn);

final ListStore<Plant> store = new ListStore<Plant>();
store.add(TestData.getPlants());

ColumnModel cm = new ColumnModel(configs);

final EditorGrid<Plant> grid = new EditorGrid<Plant>(store, cm);
grid.setAutoExpandColumn("name");
grid.setBorders(true);
grid.addPlugin(checkColumn);

ContentPanel panel = new ContentPanel();
panel.add(grid);

RootPanel.get().add(panel);
}

sven
1 Apr 2009, 4:28 AM
Fixed in SVN.