Saturday, October 29, 2011

Re: Classname.this in code split (GWT 2.4)

This is basically the code that is now failing in GWT 2.4:
public void doSomething(final String id, final String name) {
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onFailure(Throwable caught) {
Window.alert("An error occurred accessing the server.");

GWT.log("ClassName.doSomething() Async Failure", caught);
}

@Override
public void onSuccess() {
Scheduler.get().scheduleDeferred(new
TheCommand(ClassName.this, id, name));
}
});
}

My work around:
public void doSomething(final String id, final String name) {
final ClassName instance = this; //had to add to this??

GWT.runAsync(new RunAsyncCallback() {
@Override
public void onFailure(Throwable caught) {
Window.alert("An error occurred accessing the server.");

GWT.log("ClassName.doSomething() Async Failure", caught);
}

@Override
public void onSuccess() {
Scheduler.get().scheduleDeferred(new SomeCommand(instance,
id, name)); //ClassName.this was changed to instance
}
});
}

On Oct 28, 11:41 am, Patrick Tucker <tucker...@gmail.com> wrote:
> Has anyone else had trouble with usingClassname.thisin a code split
> block?
>
> The code I'm referring to worked fine in 2.3 but throws a NPE when I
> updated it to 2.4.
>
> I have a work around but not looking forward to finding all the places
> where it is now broken.
>
> Thanks,
> Pat

--
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-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment