Categories
Uncategorized

GWT Callback parameter should be defined as final

It is convenient to just write java code and got converted into JavaScript. however there is a common compile error that will cause the compiler not able to compile the source code into java script. one of them is to provide a
*final* call back object with will be used inner class.

for example, in the following pseudo method:
public class JZCallBackService{

public void createObject(Foo dto, final CallbackObject callback) {

Ajax.Call(URL, new RestfulCallback() {
@Override
public void onSuccessful(Request request, Response response) {
callback.doSomthing();
}
});
}
}
if the CallbackObject is not defined as final, gwt compile will not be able to compile this class and an exception that JZCallBackService is not available to be used.