Vaadin JavaScript server-side component
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
@StyleSheet({"colorPicker.css"}) | |
@JavaScript({"vue.js","es6-promise.auto.js", "vuex.js", "bundle.js", "vaadin-injector.js"}) | |
public class VueComponent extends AbstractJavaScriptComponent { | |
private Consumer<Color> onColorChangedConsumer; | |
public VueComponent() { | |
setId("app"); | |
addFunction("onSyncColorPicker", arguments -> { | |
Notification.show("Message from VUE: " + arguments.get(0).asString()); | |
if (onColorChangedConsumer != null) { | |
int r = (int)arguments.getObject(0).getObject("rgba").getNumber("r"); | |
int g = (int)arguments.getObject(0).getObject("rgba").getNumber("g"); | |
int b = (int)arguments.getObject(0).getObject("rgba").getNumber("b"); | |
int a = (int)arguments.getObject(0).getObject("rgba").getNumber("a"); | |
Notification.show("Color Changed to r:" + r + ", g:" + g + ", b:" + b + ", a:" + a); | |
onColorChangedConsumer.accept(new Color(r, g, b, a)); | |
} | |
}); | |
} | |
public void onColorChanged(Consumer<Color> onColorChangedConsumer) { | |
this.onColorChangedConsumer = onColorChangedConsumer; | |
} | |
@Override | |
public VueState getState() { | |
return (VueState)super.getState(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment