Announcement

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

    "Unable to get property 'name' of undefined or null reference" on IE & GWT 2.7 only

    Hi,

    The following code works on Chrome & Firefox, but not on IE. The error appears at "return getName();" and only if GWT 2.7 is used. Same behavior for SmartGWT 5 & 5.1 (latest builds)

    Code:
    package com.smartgwt.sample.showcase.client.forms;
    
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ButtonItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
    import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
    import com.smartgwt.sample.showcase.client.PanelFactory;
    import com.smartgwt.sample.showcase.client.ShowcasePanel;
    
    public class FormFocusFirstSample extends ShowcasePanel {
        private static final String DESCRIPTION = "<p>Setting the focus / cursor on the first field of a form is common requirement. Doing this in Smart GWT is as simple as setting <code>form.setAutoFocus(true)</code>.</p>" +
                "<p>This sample also has <code>setSelectOnFocus(true)</code> on the first field.</p>";
    
        public static class Factory implements PanelFactory {
            private String id;
    
            public ShowcasePanel create() {
                FormFocusFirstSample panel = new FormFocusFirstSample();
                id = panel.getID();
                return panel;
            }
    
            public String getID() {
                return id;
            }
    
            public String getDescription() {
                return DESCRIPTION;
            }
        }
    
        public Canvas getViewPanel() {
    
            final DynamicForm form = new DynamicForm();
            form.setAutoFocus(true);
            form.setNumCols(3);
            form.setWidth(300);
    
            TextItem firstName = new TextItem("fName") {
                @Override
                public String toString() {            
                    return getName();
                }
            };
            firstName.setName("firstName");
            firstName.setTitle("First Name");
            firstName.setSelectOnFocus(true);
            firstName.setWrapTitle(false);
            firstName.setDefaultValue("[First Name]");
    
            TextItem lastName = new TextItem("lName");
            lastName.setTitle("Last Name");
            lastName.setDefaultValue("[Last Name]");
            lastName.setWrapTitle(false);
    
            ButtonItem button = new ButtonItem("hello", "Hello");
            button.setStartRow(false);
            button.setWidth(80);
            button.setIcon("icons/16/message.png");
            button.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    SC.say("Hello " + form.getValueAsString("fName") + " " + form.getValueAsString("lName"));
                }
            });
    
            form.setFields(firstName, lastName, button);
    
            return form;
        }
    
        public String getIntro() {
            return DESCRIPTION;
        }
    }

    #2
    So the problem is related to your toString() override?

    It's very possible this is some kind of problem in your environment, in which case we wouldn't be able to reproduce it.

    Can you tell us:
    1. What're actual error is - the stack trace of one is shown
    2. Anything appearing in the SmartGWT Developer Console
    3. Exact version of IE, and Windows
    4. Does the error happen in GWT "classic" Development mode, SuperDevMode, compiled mode? Do you get better information in any of these modes?

    Comment


      #3
      This is the log from SmartGWT Developer Console. The sample code is just a modified FormFocusFirstSample. If you try to open the sample from showcase tree, nothing is shown.

      3. IE11 (didn't test it on older versions), Windows 7 and 10
      4. SuperDevMode and production mode.

      Code:
      22:34:53.375:pointerup3:WARN:Log:com.google.gwt.core.client.JavaScriptException: (TypeError) : Unable to get property 'name' of undefined or null reference
          at BKc(Unknown script code)
          at dKd(Unknown script code)
          at toString(Unknown script code)
          at isc_isA_Function(http://localhost:8080/showcase/showcase/sc/modules/ISC_Core.js?isc_version=10.1p.js)
          at isc_addPropertyList(http://localhost:8080/showcase/showcase/sc/modules/ISC_Core.js?isc_version=10.1p.js)
          at isc_addProperties(http://localhost:8080/showcase/showcase/sc/modules/ISC_Core.js?isc_version=10.1p.js)
          at isc_Class_completeCreation(http://localhost:8080/showcase/showcase/sc/modules/ISC_Core.js?isc_version=10.1p.js)
          at isc_DynamicForm_createItem(http://localhost:8080/showcase/showcase/sc/modules/ISC_Forms.js?isc_version=10.1p.js)
          at isc_DynamicForm__addItems(http://localhost:8080/showcase/showcase/sc/modules/ISC_Forms.js?isc_version=10.1p.js)
          at isc_DynamicForm__setItems(http://localhost:8080/showcase/showcase/sc/modules/ISC_Forms.js?isc_version=10.1p.js)

      Comment


        #4
        After investigating, we're convinced that this is either a GWT bug or a bug in IE. The behavior is that in IE only, the object used as "this" inside the generated JavaScript is entirely the wrong object.

        In order to prevent this issue you can use this version of your method:
        Code:
         @Override
           public native String toString() /*-{
              var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();
              if (self == null) return "";
              else return self.getName();
          }-*/;
        Regards
        Isomorphic Software

        Comment

        Working...
        X