Skip to content

Instantly share code, notes, and snippets.

@mcollovati
Last active September 5, 2017 21:12
Show Gist options
  • Save mcollovati/69d61662381618c5d123c733dd2c9b12 to your computer and use it in GitHub Desktop.
Save mcollovati/69d61662381618c5d123c733dd2c9b12 to your computer and use it in GitHub Desktop.
window.com_github_mcollovati_vaadin_MyExtension = function() {
var me = this;
var btn = me.getElement(me.getParentId());
btn.onclick = function() {
// call external lib with extension callback
externalLib.doSomething(me.myCallback);
}
}
@JavaScript("myextension.js", "externallib.js")
public class MyExtension extends AbstractJavaScriptExtension {
private MyExtension(AbstractClientConnector target) {
super(target);
addFunction("myCallback", args -> {
// Do something with callack args
});
}
static MyExtension extend(Button button) {
return new MyExtension(button);
}
}
public class MyUI extends UI {
protected void init(VaadinRequest vaadinRequest) {
...
Button copy = new Button("Do something");
MyExtension.extend(copy);
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment