0
votes

In Jsni Example to call a java method from javascript we wirte this

            $wnd.testJSNI=
        @com.jsni.client
        .HelloJSNI::testJSNI(Ljava/lang/String;)(test);

I try to figure out,but could'nt find what we exactly meant by Ljava/lang/String? and do we necessarily pass these arguments?

2

2 Answers

3
votes

The Ljava/lang/String; tells GWT that the method expects a String parameter, which will be passed in as the test value in your sample code.

In general in JSNI methods you need to tell GWT what the parameter types are, or you can use the shortcut (*) which tells GWT to figure it out for itself. This works in most cases as far as I've seen. So your code could also be written as:

var test = 'This is my test string';
$wnd.testJSNI = @com.jsni.client.HelloJSNI::testJSNI(*)(test);
-1
votes

That 'Ljava/lang/String;" format looks like JNI. It's used to describe, in text, a data type. You can read more here.