I was looking all around the samples but still can't get it... How to write such kind of function in JSNI as
function test(a)
{
return a+' is parameter';
}
I mean to be able get JS function return value with GW开发者_如何学编程T... ?
All useful comments are appreciated
JSNI function calls are defined like that:
public final native String test(String a) /*-{
return a + 'is parameter;
}-*/;
The important part of the function signature is final native and the opening and closing brackets.
Fore more information on how to write and use JSNI see here.
If you have more complex return types also check out JavaScript Overlays Types.
Use JsArrayString
if you wish to return an array of the string.
This is helpful to overcome the following exception:
java.lang.ClassCastException: com.google.gwt.core.client.JavaScriptObject$ cannot be cast to [Ljava.lang.String;
精彩评论