开发者

GWT JSNI and return function - need advice

开发者 https://www.devze.com 2023-03-18 10:36 出处:网络
I was looking all around the samples but still can\'t get it... How to write such kind of function in JSNI as

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;

0

精彩评论

暂无评论...
验证码 换一张
取 消