Wednesday, April 20, 2016

Re: GWT app as includable javascript library

yes definitely.

With jsinterop it is supposed to be straight forward but even with the older JSNI method it is easy enough if you have a small number of methods to export.

Let's say you want to export a method from your java code. The object hosting the method is MyJavaObject and the method is int myJavaMethod(String str, int index); The js method is myJsMethod


    public static native void exportJSNI(MyJavaObject that) /*-{
        $wnd.myJsMethod = $entry(function(str) {
            that.@com.my.package.MyJavaObject::myJavaMethod((Ljava/lang/String;Z)(str, index);
        });

        //... more exports if you like

       // another tip
if the page has defined a callback - use it to notify the page that your code is ready to be used
        if (typeof $wnd.onMyJavaObjectLoad === "function") {
            $wnd.onMyJavaObjectLoad();
        }
    }-*/;




On Thu, Apr 21, 2016 at 7:54 AM, Dmitry Skavish <skavish@gmail.com> wrote:
hey everyone,

I am trying to understand how can I package my small gwt app as javascript library which can be used in other javascript code. 

Basically I need to build a bunch of java code into a single .js file which I can later include in a regular html page with <script> tag and call some methods defined in this gwt built js file.

Is that even possible?
​​

--
Dmitry Skavish

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.



--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment