I have an application that uses the ScreenLoaderServlet to serve up some of the layouts from *.ui.xml files on the server. When moving the application from SmartGWT EE 4.0 to SmartGWT EE 4.1, I get an exception trying to access HLayout and VLayout children of a given screen using Canvas.getByLocalId(). Here is the code snippet where the exception is thrown:
Code:
RPCManager.cacheScreens(displayList.toArray(new String[{"Master"}), new Function() {
@Override
public void execute() {
Canvas masterPane = RPCManager.createScreen("Master");
// Interesting that this line here for the TabSet does
// NOT throw an error
TabSet tabs = (TabSet) masterPane.getByLocalId("MainTab");
tabs.getTabBar().setAlign(Alignment.CENTER);
// This object is actually in HLayout in the markup,
// and it throws an assertError as described below.
Canvas ctr = masterPane.getByLocalId("HomeContainer");
}
};
With a little debugging, the error appears to be that even though "HomeContainer" is really an HLayout, it's Java object reference gets set to a plain Canvas somewhere before HLayout.getOrCreateRef is called. I was unable to figure it out beyond that. Here's the complete stack trace:
java.lang.AssertionError: null
at com.smartgwt.client.widgets.layout.HLayout.getOrCr eateRef(HLayout.java:107)
at com.smartgwt.client.widgets.layout.HLayout.getOrCr eateRef(HLayout.java:1)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(Meth odAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(Met hodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invok e(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reac tToMessagesWhileWaitingForReturn(BrowserChannelSer ver.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invo keJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke (ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative( ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeO bject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNati veObject(JavaScriptHost.java:91)
at com.smartgwt.client.util.ObjectFactory.createCanva s(ObjectFactory.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(Meth odAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(Met hodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invok e(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reac tToMessagesWhileWaitingForReturn(BrowserChannelSer ver.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invo keJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke (ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative( ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeO bject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNati veObject(JavaScriptHost.java:91)
at com.smartgwt.client.widgets.Canvas.getByJSObject(C anvas.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(Meth odAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(Met hodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invok e(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reac tToMessagesWhileWaitingForReturn(BrowserChannelSer ver.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invo keJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke (ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative( ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeO bject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNati veObject(JavaScriptHost.java:91)
at com.smartgwt.client.widgets.Canvas.getByLocalId(Ca nvas.java)
at com.eterra.tdm.ui.client.view.smartgwt.SgwtMasterT dmView$1.execute(SgwtMasterTdmView.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(Meth odAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(Met hodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invok e(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reac tToMessagesWhileWaitingForReturn(BrowserChannelSer ver.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invo keJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke (ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative( ModuleSpace.java:576)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeO bject(ModuleSpace.java:284)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNati veObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.ja va)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.j ava:347)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unkno wn Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(Meth odAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(Met hodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invok e(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reac tToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.proc essConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run( BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:744)
Here's the RPC return from cacheScreens:
[
{
screenName:"Master",
source:"\n\t\n\tisc.HLayout.create({\n ID:\"HomeContainer\",\n autoDraw:false\n})\n\n\tisc.VLayout.create({\n ID:\"ComponentsContainer\",\n autoDraw:false\n})\n\n\tisc.VLayout.create({\n ID:\"BuildsContainer\",\n autoDraw:false\n})\n\n\tisc.VLayout.create({\n ID:\"ReleasesContainer\",\n autoDraw:false\n})\n\n\tisc.VLayout.create({\n ID:\"DeploymentsContainer\",\n autoDraw:false\n})\n\n\tisc.Label.create({\n Align:\"LEFT\",\n ID:\"separatorBar\",\n contents:\"|\",\n height:40,\n styleName:\"indentedHiliteTitle\",\n width:10\n})\n\n\tisc.Img.create({\n Align:\"LEFT\",\n ID:\"testImg\",\n imageType:\"CENTER\",\n size:40,\n src:\"icn_action_req.svg\"\n})\n\n\tisc.Label.crea te({\n Align:\"RIGHT\",\n ID:\"jobname\",\n VAlign:\"BOTTOM\",\n contents:\": Jobname1234\",\n height:40\n})\n\n\tisc.LayoutSpacer.create({\n ID:\"spacer1\",\n width:\"50%\"\n})\n\n\t\t\n\tisc.HLayout.create({\ n ID:\"titleBar\",\n height:10,\n styleName:\"topBarStyle\",\n width:\"100%\",\n members:[\n spacer1,\n testImg,\n jobname\n ]\n})\n\t\n\t\t\n\tisc.TabSet.create({\n ID:\"MainTab\",\n autoDraw:false,\n height:\"*\",\n width:\"100%\",\n tabs:[\n {\n canClose:false,\n title:\"__Home\",\n pane:HomeContainer,\n ID:\"TabHome\"\n },\n {\n canClose:false,\n title:\"__Components\",\n pane:ComponentsContainer,\n ID:\"TabComponents\"\n },\n {\n canClose:false,\n title:\"__Builds\",\n pane:BuildsContainer,\n ID:\"TabBuilds\"\n },\n {\n canClose:false,\n title:\"__Releases\",\n pane:ReleasesContainer,\n ID:\"TabReleases\"\n },\n {\n canClose:false,\n title:\"__Deployments\",\n pane:DeploymentsContainer,\n ID:\"TabDeployments\"\n }\n ],\n canCloseTabs:false,\n destroyPanes:false,\n symmetricEdges:true,\n showResizeBar:false,\n showShadow:false\n})\n\n\t\n\tisc.VLayout.create({ \n ID:\"MainContainer\",\n height:\"100%\",\n width:\"100%\",\n members:[\n titleBar,\n MainTab\n ]\n})\n\n\t\n\n"
}
]
Version info from developer console:
SmartClient Version: v9.1p_2014-03-25/Enterprise Deployment (built 2014-03-25)