-
17 Jun 2009 6:51 AM #1
[CLOSED] AggregationRowConfig with RPC return null pointer
[CLOSED] AggregationRowConfig with RPC return null pointer
set the class Customer to
change the code in BeanModelGridExample toCode:public class Customer implements BeanModelTag, Serializable {
on method getCustomers() of the class ExampleServiceImpl, add one break point inCode:public class BeanModelGridExample extends LayoutContainer { @Override protected void onRender(Element parent, int index) { super.onRender(parent, index); setStyleAttribute("padding", "20px"); GridCellRenderer<BeanModel> render = new GridCellRenderer<BeanModel>() { public Object render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BeanModel> store, Grid<BeanModel> grid) { return "test " + model.get("age"); } }; // gwt service final ExampleServiceAsync service = (ExampleServiceAsync) Registry.get(Examples.SERVICE); // proxy and reader RpcProxy<List<Customer>> proxy = new RpcProxy<List<Customer>>() { @Override public void load(Object loadConfig, AsyncCallback<List<Customer>> callback) { service.getCustomers(callback); } }; BeanModelReader reader = new BeanModelReader(); // loader and store ListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy, reader); ListStore<BeanModel> store = new ListStore<BeanModel>(loader); loader.load(); // column model List<ColumnConfig> columns = new ArrayList<ColumnConfig>(); columns.add(new ColumnConfig("name", "Name", 200)); columns.add(new ColumnConfig("email", "Email", 100)); ColumnConfig age = new ColumnConfig("age", "Age", 50); age.setRenderer(render); columns.add(age); AggregationRowConfig<BeanModel> totals = new AggregationRowConfig<BeanModel>(); totals.setSummaryType("age", SummaryType.AVG); totals.setRenderer("age", new AggregationRenderer<BeanModel>() { public Object render(Number value, int colIndex, Grid<BeanModel> grid, ListStore<BeanModel> store) { return NumberFormat.getCurrencyFormat().format(value.doubleValue()); } }); ColumnModel cm = new ColumnModel(columns); cm.addAggregationRow(totals); Grid<BeanModel> grid = new Grid<BeanModel>(store, cm); grid.setAutoExpandColumn("name"); grid.setSize(400, 200); add(grid); }
DEBUG the GXT explorer demo application and click to see the BeanModelGrid example.. you will see that the grid will render.. and return a null pointer exception.. so.. click in button Resume(F8) the data will render and the aggregation row will appears correctely..Code:return customers;
Real situation.. when call a remote procedure.. can be a complex calc and delay more than the normal..
I believe that the behavior of the aggregation row should be like GridCellRenderer
-
17 Jun 2009 6:58 AM #2
in ColumnFooter you need verify in the line 228
add this condition
Code:if (value != null) { Object obj = renderer.render(value, j, (Grid) grid, (ListStore) store); }
-
17 Jun 2009 7:00 AM #3
other real situation.. the RPC need access other database.. that delay more than normal..
-
17 Jun 2009 7:03 AM #4
The issue is in your renderer and not GXT. I close this issue.
-
17 Jun 2009 7:36 AM #5
no!
to solve this I always need add this condition in my code..
Code:totals.setRenderer("age", new AggregationRenderer<BeanModel>() { public Object render(Number value, int colIndex, Grid<BeanModel> grid, ListStore<BeanModel> store) { if (value != null) { return NumberFormat.getCurrencyFormat().format(value.doubleValue()); } else { return ""; } } });
-
17 Jun 2009 7:37 AM #6
yes and that is correct. If value is null you cant call doubleValue on it.
-
17 Jun 2009 7:40 AM #7
yes I know about this

the problem that this method is called twice.. when the grid is render.. that the value is null and when the data its load.. I believe that if the value is null, cannot call the method render.. because in all situation will return null pointer..
-
17 Jun 2009 7:41 AM #8
Also that is correct. The footer should also be displayed with 0 records in the grid.
-
17 Jun 2009 7:44 AM #9
I agree with you.. but only the html and widget can be render when have 0 records..
the method render no can.. because what the value for average sum and other when dont have records?
-
17 Jun 2009 7:46 AM #10
That is why you define a renderer. So you can say what should be displayed in that case.
Thank you for reporting this bug. We will make it our priority to review this report.



Reply With Quote