PDA

View Full Version : [FIXED] Null Pointer in SummaryType - rc1



fother
25 Jun 2009, 8:54 AM
code example



public class Gxt implements EntryPoint {

public class Data extends BaseModel {

public Data(String name, Double value) {
setName(name);
setValue(value);
}

public String getName() {
return get("name");
}

public Double getValue() {
return get("value");
}

public void setName(String name) {
set("name", name);
}

public void setValue(Double value) {
set("value", value);
}

}

public void onModuleLoad() {

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

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Name");
column.setWidth(200);
configs.add(column);

column = new ColumnConfig();
column.setId("value");
column.setHeader("Value");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(100);
configs.add(column);

final ListStore<Data> store = new ListStore<Data>();
store.add(new Data("name 1", null));
store.add(new Data("name 2", null));
store.add(new Data("name 3", null));
store.add(new Data("name 4", null));
store.add(new Data("name 5", null));

ColumnModel cm = new ColumnModel(configs);

AggregationRowConfig<Data> averages = new AggregationRowConfig<Data>();
averages.setSummaryType("value", SummaryType.AVG);
averages.setRenderer("value", new AggregationRenderer<Data>() {

public Object render(Number value, int colIndex, Grid<Data> grid, ListStore<Data> store) {

if (value != null) {
return NumberFormat.getCurrencyFormat().format(value.doubleValue());
} else {
return "nothing";
}
}
});

cm.addAggregationRow(averages);

Grid<Data> grid = new Grid<Data>(store, cm);
grid.setBorders(false);
grid.setAutoExpandColumn("name");
grid.setBorders(true);
grid.setSize(400, 200);

RootPanel.get().add(grid);

}
}
stacktrace


java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.grid.SummaryType$2.render(SummaryType.java:44)
at com.extjs.gxt.ui.client.widget.grid.SummaryType$2.render(SummaryType.java:1)
at com.extjs.gxt.ui.client.widget.grid.ColumnFooter.refresh(ColumnFooter.java:205)
at com.extjs.gxt.ui.client.widget.grid.ColumnFooter.onRender(ColumnFooter.java:173)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:898)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:861)

darrellmeyer
25 Jun 2009, 12:47 PM
I added null checks to all summary types.

Fixed in SVN.

fother
25 Jun 2009, 3:48 PM
good.. thanks :D