Search code examples
javagwtjsni

GWT JSNI and return function - need advice


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 GWT... ?

All useful comments are appreciated


Solution

  • 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.