PDA

View Full Version : [FNR] Showing a window with a ListView throws NullPointerException



quodroc
12 Nov 2010, 11:43 AM
Using gxt 2.2.1 with GWT 2.1.0

If a window contains a ListView before it is show, an exception is thrown.

Window window = new Window();
window.add(new ListView<BeanModel>());
window.show();

results in

java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.ListView.refresh(ListView.java:409)
at com.extjs.gxt.ui.client.widget.ListView.afterRender(ListView.java:583)
at com.extjs.gxt.ui.client.widget.Component.render(Component.java:1110)
at com.extjs.gxt.ui.client.widget.Layout.renderComponent(Layout.java:361)
at com.extjs.gxt.ui.client.widget.layout.FlowLayout.renderComponent(FlowLayout.java:110)
at com.extjs.gxt.ui.client.widget.Layout.renderAll(Layout.java:352)
at com.extjs.gxt.ui.client.widget.Layout.onLayout(Layout.java:318)
at com.extjs.gxt.ui.client.widget.layout.FlowLayout.onLayout(FlowLayout.java:102)
at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:114)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:351)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:443)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:246)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:426)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:241)
at com.extjs.gxt.ui.client.widget.Window.afterShow(Window.java:978)
at com.extjs.gxt.ui.client.widget.Window.show(Window.java:954)
at playground.gxt.client.Gxt_playground.onModuleLoad(Gxt_playground.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:619)

A workaround is to add the ListView to the window after it is shown;

Window window = new Window();
window.show();
window.add(new ListView<BeanModel>());

sven
12 Nov 2010, 8:23 PM
A ListView requires a ListStore. Also it did not throw an exception befor, a liststore was still required. I will change the code but you should also fix your code.

sven
22 Nov 2010, 3:47 AM
I changed the code so it renders without a liststore too. Change is in SVN at revision 2334