Last active
September 5, 2017 21:12
-
-
Save mcollovati/69d61662381618c5d123c733dd2c9b12 to your computer and use it in GitHub Desktop.
This file contains 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
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