Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Although you can set the compiler to output 'pretty' code, I suggest you write export functions for the classes you want to call from outside your GWT project. I believe somewhere in the GWT documentation it's detailed how to do this, but I couldn't find it so here an example I just created.</p> <pre><code>class YourClass { public YourClass() { ... } public void yourMethod() { ... } public static YourClass create() { return new YourClass(); } public final static native void export() /*-{ $wnd.YourClass = function() { this.instance = new @your.package.name.YourClass::create()() } var _ = $wnd.YourClass.prototype; _.yourMethod = function() {this.instance.@your.package.name.YourClass::yourMethod()()} }-*/; } </code></pre> <p><strong>EDIT</strong></p> <p>To elaborate, your code will get obfuscated like normal, but thanks to the export function, you can easily reference those functions externally. You <em>don't</em> have to rewrite anything from your Java class in JavaScript. You only write the references in JavaScript, so you can do this:</p> <pre><code>var myInstance = new YourClass(); myInstance.yourMethod(); </code></pre> <p>Of course you have to call the static export method from somewhere in your GWT app (most likely in your EntryPoint) to make this work.</p> <p>More info about referencing Java methods from JavaScript: <a href="http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#methods-fields">http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#methods-fields</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload