Just a silly mistake, but could be useful for someone.

In my Ui Binder style widget I had a default 0-arg constructor that
looks like this:

public MyWidget() {
        initWidget(binder.createAndBindUi(this));
}

... and then later I decided I needed an additional constructor that
takes args, but I forgot to call
initWidget(binder.createAndBindUi(this)); in the second constructor.
So now I have:

public MyWidget(String message) {
        this(); // invoke my first default constructor which does the UI
binding
        this.message = message;
}

Later I had a line of code that said myDivElement.setInnerText(label);
but myDivElement was null because the Ui Binder had not "bound" yet.
This was the cause of the message:
Cannot set property 'textContent' of null


All fixed, shan't be making that error again!



On Sep 28, 11:27 am, Paul Schwarz <paulsschw...@gmail.com> wrote:
> Using GWT 2.1 M3 and making use of Ui Binder widgets, and having done
> some refactoring elsewhere I now get the odd UI related error that
> looks like the following. I have no clue where to start tracing it and
> doing null checks or whatever, someone, please give me a hint!
>
> com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot
> set property 'textContent' of null
>  stack: TypeError: Cannot set property 'textContent' of null
>     at [object Object].<anonymous> (unknown source)
>     at __gwt_jsInvoke (http://192.168.0.223:8888/cabs/hosted.html?cabs:
> 76:35)
>     at eval at <anonymous> (http://192.168.0.223:8888/cabs/hosted.html?
> cabs:54:12)
>     at XMLHttpRequest.<anonymous> (unknown source)
>     at unknown source
>     at __gwt_jsInvoke (http://192.168.0.223:8888/cabs/hosted.html?cabs:
> 76:35)
>     at eval at <anonymous> (http://192.168.0.223:8888/cabs/hosted.html?
> cabs:54:12)
>     at XMLHttpRequest.onreadystatechange (unknown source)
>  type: non_object_property_store
>  arguments: textContent,
>  __gwt_ObjectId: 28258
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChann 
> elServer.java:
> 237)
>     at
> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
> 126)
>     at
> com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
> 552)
>     at
> com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
> 269)
>     at
> com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j 
> ava:
> 91)
>     at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
>     at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
>     at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>     at java.lang.reflect.Method.invoke(Unknown Source)
>     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.jav a:
> 157)
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChanne 
> lServer.java:
> 281)
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan 
> nelServer.java:
> 531)
>     at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java :
> 352)
>     at java.lang.Thread.run(Unknown Source)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to