Saturday, January 17, 2015

Re: help understanding complicated client logs

You can test it locally if you use Chrome DevTools. When you open DevTools you can click on the small mobile device icon on the left side right next to the search icon. Once you have done that you should see a new dark toolbar at the top of your page which has a Network drop down which allows you to emulate slower network conditions in Chrome.

Given your stack trace it seems like you called AbsolutePanel.add(childWidget) somewhere but your instance of AbsolutePanel was null.

For your understanding how to read these stack frames:

__gwt$exception: <skipped>: Cannot read property 'com_google_gwt_user_client_ui_UIObject_element' of null
   at Unknown.com_google_gwt_user_client_ui_AbsolutePanel_$add__Lcom_google_gwt_user_client_ui_AbsolutePanel_2Lcom_google_gwt_user_client_ui_Widget_2V

First line is the JavaScript exception message which says you have tried to access UIObject.element but UIObject was null. Since UIObject has a getElement() method that means your java code did call "null.getElement()". At the next line you see that this happened in AbsolutePanel.$add(AbsolutePanel, Widget). This method has been generated by the GWT compiler and is a static version of AbsolutePanel.add(Widget). These generated static methods are marked with "$" by GWT. Given the implementation of AbsolutePanel.add(Widget) it seems like your instance of AbsolutePanel was null.

Your code did something like:

AbsolutePanel myPanel = null; // somehow the variable was null
myPanel.add(child);

with AbsolutePanel.add() being implemented as:

public void add(Widget w) {
   super.add(w, getElement());
}

GWT compiler changed your method call to a static method call

AbsolutePanel.$add(myPanel, w);

And the implementation of $add is probably similar to

public static void $add(AbsolutePanel instance, Widget w) {
  ComplexPanel.$add(w, instance.getElement());
}

The bold code causes the exception. Since getElement() and the element field are defined on UiObject the exception message says you have tried to access UiObject.element with UiObject being null.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment