Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Nullpointer in IDManager

    Hi,

    We are upgrading from v9.0p_2013-07-17/Pro Deployment to v9.0p_2013-09-02/Pro Deployment 2013-09-02 and are hitting a nullpointer after using the new version.

    This is the error trace:
    Code:
    com.smartgwt.client.util.IDManager.validateID(IDManager.java:68)
    com.smartgwt.client.util.IDManager.registerID(IDManager.java:118)
    com.smartgwt.client.widgets.BaseWidget.internalSetID(BaseWidget.java:387)
    com.smartgwt.client.widgets.menu.Menu.setJavaScriptObject(Menu.java:106)
    com.smartgwt.client.widgets.menu.Menu.<init>(Menu.java:143)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
    com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    com.smartgwt.client.widgets.menu.Menu.getOrCreateRef(Menu.java)
    com.smartgwt.client.widgets.menu.MenuItem.getSubmenu(MenuItem.java:416)
    foo.bar.custom.widgets.FooListGrid.getHeaderContextMenuItems(FooListGrid.java:1249)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    java.lang.Thread.run(Thread.java:662)
    I did some backtracing and it seems that it starts happening in v9.0p_2013-07-28/Pro Deployment 2013-07-28 already.

    The error is thrown while a page/canvas is being loaded/build that contains a listgird. The call to 'getHeaderContextMenuItems' inspects the menuitems which do not have an ID set at that time - somehow the system thinks that they do and things go wrong.

    Thanks for investigating.

    #2
    We see the problem and are investigating.

    Comment


      #3
      Thanks, I just spent a few days tracking down another upgrade related issue that also seems to be caused by IDManager functionality. This is the case:

      In our custom FooListGrid we have some custom code that fires after the grid went into edit mode, we retrieve the form of the edited record there using our following method:

      Code:
      public native DynamicForm getEditForm() /*-{
      	var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
      	if (!self.getEditForm) return null;
      	var form = self.getEditForm();
      	return @com.smartgwt.client.widgets.form.DynamicForm::new(Lcom/google/gwt/core/client/JavaScriptObject;)(form);		
      }-*/;
      It accesses the local edit form of the grid - worked fine until now.

      What's important here is the last line, where we call the constructor of DynamicForm from JS to wrap the obtained object into it's typed form.
      This is where things go wrong, the new code located in the DynamicForm Java wrapper does as follows:

      Code:
          public DynamicForm(JavaScriptObject jsObj){
              scClassName = "DynamicForm";
              setJavaScriptObject(jsObj);        
          }
      and especially:

      Code:
          public void setJavaScriptObject(JavaScriptObject jsObj) {
              internalSetID(jsObj);
              JSOHelper.setObjectAttribute(jsObj, SC.REF, this);
              onBind();
          }
      Before it did the following:
      Code:
          public DynamicForm(JavaScriptObject jsObj){
              scClassName = "DynamicForm";
              setJavaScriptObject(jsObj);
              
          }
      and especially:

      Code:
          public void setJavaScriptObject(JavaScriptObject jsObj) {
              id = JSOHelper.getAttribute(jsObj, "ID");
          }
      Somehow the new logic causes the original form to be replaced by a new one, after which the fields are gone and the nullpointers we where having on the form items occur (the result was that the grid went into edit mode but locked up completely afterwards).
      I'm not sure that this (adapted logic in the constructor) was intended to work this way, I assume not.

      We can adapt the code in our method to the following:

      Code:
      public native DynamicForm getEditForm() /*-{
      	var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
      	if (!self.getEditForm) return null;
      	var form = self.getEditForm();
      	return @com.smartgwt.client.widgets.form.DynamicForm::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(form);
      }-*/;
      Which cures the ListGrid edit issue. The only problem is, what with all other calls to that particular contructor. And are other constructors for other objects impacted as well? Please advise what we should do here.

      Comment


        #4
        The SGWT Class constructors taking a JavaScript object were intended only for internal use by our object life cycle management code, and not for customer use. The public scope is only due to access restrictions between packages in Java.

        The suggestion to use getOrCreateRef() will work, but we recommend a newly added set of APIs, asSGWTComponent(). Currently these are in SGWT 4.1d only, but we'll try to get them merged back to SGWT 4.0p for the next nightly build. Functionally the new APIs do the same thing as getOrCreateRef() but provide more friendly warnings.

        The above applies to all Canvas classes - you should not be calling new on the JavaScriptObject constructor directly.

        Comment


          #5
          Thanks for the information, we simply did not know that. I'll wait for the changes to come trough and adapt our code to the new API directly.Thanks!

          Comment


            #6
            Can we have an ETA on this fix please, we would like to be able to upgrade to a recent build soon. Thanks.

            Comment


              #7
              The asSGWTComponent() APIs were added for SGWT 4.0p the day it was promised, so that's already in. The crash for MenuItem.getSubmenu() should have been fixed long ago, though we're going to deprecate the MenuItem.getSubmenu() API and instead provide Menu.getSubmenu() as that's really logical place to provide the correct support. That will happen this week.

              Whether you need to switch from the deprecated API to get proper functionality depends on how you're using the obtained Menu, and as you haven't provided the code, we can't speculate.

              Comment


                #8
                Hi,

                Thanks, I assumed that you would follow up to state that it was added - you guys are terrific!

                We are using the call only to get a handle to the menu to keep a reference to it - as it is a customized implementation of Menu we need to do some additional cleaning up when the menu is destroyed. I'm pretty sure that the api change will also work.

                cheers.

                Comment

                Working...
                X