Created
August 23, 2016 22:19
-
-
Save branflake2267/57fa08114e4496f9f3c3a832190c3302 to your computer and use it in GitHub Desktop.
A simple example using JsInterop to export for third party api use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gwt.core.client.EntryPoint; | |
import com.google.gwt.user.client.ui.HTML; | |
import com.google.gwt.user.client.ui.IsWidget; | |
import com.google.gwt.user.client.ui.RootPanel; | |
import com.google.gwt.user.client.ui.Widget; | |
import com.sencha.gwt.jsinterop.examples.processor.Example; | |
import jsinterop.annotations.JsType; | |
/** | |
* Don't forget to add -generateJsInteropExports to the compiler arguments for use in production. | |
*/ | |
@Example(name = "JsInterop Export Example", category = "GWT", icon = "java") | |
public class JsInteropExportExample implements EntryPoint, IsWidget { | |
@JsType(namespace = "myapi") | |
public static class User { | |
public String firstName; | |
public String lastName; | |
public final String getFullName() { | |
return firstName + " " + lastName; | |
} | |
} | |
private HTML widget; | |
@Override | |
public void onModuleLoad() { | |
RootPanel.get().add(this); | |
} | |
@Override | |
public Widget asWidget() { | |
if (widget == null) { | |
User person = new User(); | |
person.firstName = "Brandon"; | |
person.lastName = "Donnelson"; | |
widget = new HTML("FullName=" + person.firstName); | |
} | |
return widget; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment