quarks
quarks

Reputation: 35346

How to export GWT library project (not as jar) but as Javascript (js) library?

For example I have a library with this main function:

public class Xlib{
    public static XRequest get(String url){
        return new Xequest(url);
    };
}

How can this be usable to Javascript as third-party library using preferably JsInterop method?

Upvotes: 1

Views: 117

Answers (1)

Темка тоже
Темка тоже

Reputation: 357

Java:

package test;

import jsinterop.annotations.JsType;

@JsType
class XRequest{

    private String url;
    public XRequest(String url)
    {
    this.url=url;

    }

    public String testGet()
    {
    return url;
    }

    };
@JsType
class Xlib{
    public static XRequest get(String url){
        return new Xequest(url);
    };
}

JS:

var xr = test.Xlib.get('stackoverflow');
xr.testGet();//return 'stackoverflow'

Upvotes: 1

Related Questions