JavaScriptObject

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:

public interface JavaScriptMethodCallback
{
	public void execute(JavaScriptObject obj);
}
	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;
	}-*/;
....
JavaScriptMethodHelper.registerCallbackFunction(new JavaScriptMethodCallback() {
			public void execute(JavaScriptObject obj)
			{
				System.err.println(obj.toString());
			}
		});
....

The function call was successfully invoked, because I get an alert box from this line:

$wnd.alert(j);

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.

This isn’t really a SmartGWT question, just a GWT question, but probably it’s because you’re passing a String “HELLO”, when when passed through JSNI becomes a Java String, not a JavaScriptObject. JavaScriptObject is used to represent Object, Array and potentially Date.