use of com.vaadin.flow.component.html.Span in project flow by vaadin.
the class ExportedJSFunctionView method onShow.
@Override
protected void onShow() {
Div version = new Div();
version.setId("version");
add(version);
String client = "window.Vaadin.Flow.clients[Object.keys(window.Vaadin.Flow.clients)]";
String versionJs = "var msg = '';" + "var versionInfoMethod = " + client + ".getVersionInfo;" + "if (versionInfoMethod) {" + " msg += 'version: '+versionInfoMethod().flow;" + //
"} else {" + //
" msg += 'versionInfoMethod not published';" + //
"}" + "$0.innerHTML = msg;";
getPage().executeJavaScript(versionJs, version);
Div productionMode = new Div();
productionMode.setId("productionMode");
add(productionMode);
String productionModeJs = "var productionMode = " + client + ".productionMode;" + "$0.innerText = 'Production mode: '+productionMode;";
getPage().executeJavaScript(productionModeJs, productionMode);
Div div = new Div();
div.setId("poll");
div.setText("Click to poll using JS API");
getPage().executeJavaScript("$0.addEventListener('click', function() {" + client + //
".poll();" + "});", div);
add(div);
Span pollCounter = new Span("No polls");
pollCounter.setId("pollCounter");
add(pollCounter);
UI.getCurrent().addPollListener(e -> {
pollCount++;
pollCounter.setText("Poll called " + pollCount + " times");
});
}