I am trying to invoke a javascript function within an iframe. My servlet returns:
<script type="text/javascript">window.top.callback0("HELLO");</script>
I have the following code:
The function call was successfully invoked, because I get an alert box from this line:
However, I am getting a "uncaught exception: java.lang.ClassCastException" after the alert box according to Firebug and my Java system println was not executed. Can you point out what I am missing?
Thx.
<script type="text/javascript">window.top.callback0("HELLO");</script>
I have the following code:
Code:
public interface JavaScriptMethodCallback { public void execute(JavaScriptObject obj); }
Code:
private native static void createCallbackFunction(JavaScriptMethodCallback obj, String callbackName)/*-{ tmpcallback = function( j ){ $wnd.alert(j); obj.@client.JavaScriptMethodCallback::execute(Lcom/google/gwt/core/client/JavaScriptObject;)( j ); }; $wnd[callbackName]=tmpcallback; }-*/;
Code:
.... JavaScriptMethodHelper.registerCallbackFunction(new JavaScriptMethodCallback() { public void execute(JavaScriptObject obj) { System.err.println(obj.toString()); } }); ....
Code:
$wnd.alert(j);
Thx.
Comment