django
django

Reputation: 153

JSNI method in GWT

Until I had this situation, it works :

JS side:

jsMethod : function(){...}

GWT Java side:

public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;
    test.jsMethod();    
}-*/;

The problem is when I try to do something like this

JS side

jsMethod : function(a, b){... return string}

GWT Java side

String a = 'yes'
String b = 'no'

public static native void javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b);   
}-*/;

I would be to pass parameter from GWT to JS and then returns a String but I dont' know how to make it. Thank you .

Upvotes: 0

Views: 195

Answers (2)

You can add parameters to the native JavaMethod

public static native String javaMethod(JavaScriptObject obj, String a, String b)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b);
    return testString;
}-*/;

Upvotes: 0

Suresh Atta
Suresh Atta

Reputation: 121998

Just like Java. Return a String.

public static native String javaMethod(JavaScriptObject obj)  /*-{
    var test = null;
    test = ... ;

    var testString = null;
    testString = test.jsMethod(a, b); 
    return testString;  
}-*/;

Upvotes: 0

Related Questions