Hi,
I have to test if a listGrid will fetch data, and sometimes, I have no filtering criteria to apply, so I pass null to willFetchData, but it complains
This is a simple test snippet
Is this a known behavior? If so, why I can pass null to fetchData (to pass a callback but not a criteria) and not to willFetchData? And how can I execute some - say, cleanup - code after both an async fetch (real fetch) and a sync one (no fetch, cache hit)?
I proposed a solution in http://forums.smartclient.com/showpo...18&postcount=4 but even that solution could be undermined by this issue (I could add a try/catch, but now I suspect to misuse willFetchData)
I've attached a complete test case.
At client side I'm using
SmartClient Version: 8.0/LGPL Development Only (built 2010-10-18)
(reproduced even on SC_SNAPSHOT-2010-10-11/LGPL Development Only (built 2010-10-11))
GWT 2.0.4
Firefox 3.6.9
at server side Grails 1.3.4
Kind regards
Davide
EDIT:
I found a workaround to the exception (passing an empty Criteria obtained calling the default constructor).
This is a snippet of the test modified to prevent the exception
and the resulting behavior seems correct (tested only for SmartClient Version: SC_SNAPSHOT-2010-10-11/LGPL Development Only (built 2010-10-11))
So I think the problem still applies even though with a different phrasing: is it legal to pass a null Criteria reference? If so: when?
I have to test if a listGrid will fetch data, and sometimes, I have no filtering criteria to apply, so I pass null to willFetchData, but it complains
Code:
00:14:53.064 [ERROR] Uncaught exception escaped com.google.gwt.core.client.JavaScriptException: (String): Invoking an instance method on a null instance at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.google.gwt.dev.shell.ModuleSpace.createJavaScriptException(ModuleSpace.java:65) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:60) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.smartgwt.client.widgets.grid.ListGrid.willFetchData(ListGrid.java) at com.mycompany.project.client.Test$1.execute(Test.java:50) 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.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188) 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.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619)
Code:
listGrid.fetchData (null, new DSCallback() { @Override public void execute (DSResponse response, Object rawData, DSRequest request) { GWT.log ("async callback called for fetchData (a server fetch has just been done)"); GWT.log ("now we can proceed testing willFetchData"); //never get this log, cause willFetchData fails GWT.log ("willFetchData returned: " + listGrid.willFetchData (null)); } });
I proposed a solution in http://forums.smartclient.com/showpo...18&postcount=4 but even that solution could be undermined by this issue (I could add a try/catch, but now I suspect to misuse willFetchData)
I've attached a complete test case.
At client side I'm using
SmartClient Version: 8.0/LGPL Development Only (built 2010-10-18)
(reproduced even on SC_SNAPSHOT-2010-10-11/LGPL Development Only (built 2010-10-11))
GWT 2.0.4
Firefox 3.6.9
at server side Grails 1.3.4
Kind regards
Davide
EDIT:
I found a workaround to the exception (passing an empty Criteria obtained calling the default constructor).
This is a snippet of the test modified to prevent the exception
Code:
final Criteria emptyCriteria = new Criteria (); GWT.log ("willFetchData returned: " + listGrid.willFetchData (emptyCriteria)); listGrid.fetchData (emptyCriteria, new DSCallback() { @Override public void execute (DSResponse response, Object rawData, DSRequest request) { GWT.log ("async callback called for fetchData (a server fetch has just been done)"); GWT.log ("now we can proceed testing willFetchData"); final Boolean willFetchData = listGrid.willFetchData (emptyCriteria); GWT.log ("the second willFetchData returned: " + willFetchData); listGrid.fetchData (emptyCriteria, new DSCallback() { @Override public void execute (DSResponse response, Object rawData, DSRequest request) { if (!willFetchData) { throw new RuntimeException ("Unexpected server fetch"); } GWT.log ("very strange... another server fetch has just been done"); } }); } });
So I think the problem still applies even though with a different phrasing: is it legal to pass a null Criteria reference? If so: when?
Comment