Skip to content

Instantly share code, notes, and snippets.

@mcollovati
Last active January 24, 2017 08:19
Show Gist options
  • Save mcollovati/d1ec41b40aed5743a271b285480012fb to your computer and use it in GitHub Desktop.
Save mcollovati/d1ec41b40aed5743a271b285480012fb to your computer and use it in GitHub Desktop.
window.com_github_mcollovati_vaadin_ClipboardCopy = function() {
var me = this;
var el = me.getElement(me.getParentId());
el.onclick = function() {
console.log("exec copy");
document.execCommand('copy');
console.log("exec copy dones");
}
}
@JavaScript("copy.js")
public class ClipboardCopy extends AbstractJavaScriptExtension {
private ClipboardCopy(AbstractClientConnector target) {
super(target);
}
static ClipboardCopy extend(Button button) {
return new ClipboardCopy(button);
}
}
public class MyUI extends UI {
protected void init(VaadinRequest vaadinRequest) {
...
Button copy = new Button("Copy");
ClipboardCopy.extend(copy);
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment