GWT - JSNI - passing JavaScriptObject to Java function

643 Views Asked by At

I have an JSNI method which adds a message listener to the window.

/*-{
    var that = this;
    $wnd.addEventListener("message", function (event) {
        var params = event.message.params; 
    });
*/

Here, params is an object with key-value pairs.

I also have a class, let's call it MyClass from com.mypackage.

What I would like to do now is to call a method receiveMessage of MyClass from inside the JSNI, passing params as a JavaScriptObject object (which I assume would be best, but I'm open to suggestions - stringified JSON maybe?). However I don't know what to put as param-signature type.

[email protected]::receiveMessage( ??? )(params);

Another thing is that I'm not sure how I would handle this JavaScriptObject inside receiveMessage() to get the key-value pairs in Java.

Does anyone have any suggestions how to pass params to receiveMessage() and read it as a key value pairs?

Many thanks

0

There are 0 best solutions below