I want to call Java method test()
from JSNI variable successHandler()
. However, I get error
[ERROR] - Line 110: Missing qualifier on instance method 'com.gw.myProject.client.presenter.payments.PaymentProgramPresenter.test'
Original code:
public static native void purchase(String token) /*-{
var successHandler = function(status){ // Success handler
return @com.gw.myProject.client.presenter.payments.PaymentProgramPresenter::test()();
}
var failureHandler = function(status){ // Failure handler
// $wnd.alert('testing');
}
$doc.purchaseAction(token, successHandler, failureHandler);
}-*/;
public void test() {
this.onHide();
}
Your
test()
is not static. Therefore you will need to make it static or specify an instance or make the purchase non-static.(This error is the GWT version of "
Cannot make a static reference to the non-static method methodName() from the type TypeName
")You can find a real good tutorial at gwtproject.org
One more tip. If you create javascript Callbacks within the JSNI, wrap them with en $entry()-function:
This will enable the GWT uncaughtExceptionHandler