use of com.vaadin.flow.component.html.Div in project flow by vaadin.
the class SubPropertyModelTemplate method valueUpdated.
@EventHandler
private void valueUpdated() {
Div div = new Div();
div.setId("value-update");
div.setText(getStatus().getMessage());
((HasComponents) getParent().get()).add(div);
}
use of com.vaadin.flow.component.html.Div in project flow by vaadin.
the class DemoView method showTab.
private void showTab(String tabUrl) {
Div tab = tabComponents.get(tabUrl);
if (tab != null) {
container.removeAll();
container.add(tab);
navBar.setActive(getTabUrl(tabUrl));
tab.getElement().getNode().runWhenAttached(ui -> ui.getPage().executeJavaScript("Prism.highlightAll();"));
}
}
use of com.vaadin.flow.component.html.Div 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");
});
}
use of com.vaadin.flow.component.html.Div in project flow by vaadin.
the class InMemoryChildrenView method onShow.
@Override
protected void onShow() {
Label label = new Label();
label.setId("in-memory");
label.setText("In memory element");
getElement().appendVirtualChild(label.getElement());
getElement().getNode().runWhenAttached(ui -> ui.getPage().executeJavaScript("window.inMemoryConnector.init($0, $1)", getElement(), label));
Div target = new Div();
target.setId("target");
add(target);
NativeButton button = new NativeButton("Add copy of in-memory element to the target", event -> getElement().callFunction("useInMemoryElement", target));
button.setId("copy");
add(button);
}
use of com.vaadin.flow.component.html.Div in project flow by vaadin.
the class PageView method beforeEnter.
@Override
public void beforeEnter(BeforeEnterEvent event) {
Input input = new Input();
input.setId("input");
input.clear();
Div updateButton = new Div();
updateButton.setId("button");
updateButton.setText("Update page title");
updateButton.addClickListener(e -> {
getPage().setTitle(input.getValue());
});
Div overrideButton = new Div();
overrideButton.setId("override");
overrideButton.setText("Triggers two updates");
overrideButton.addClickListener(e -> {
getPage().setTitle(input.getValue());
getPage().setTitle("OVERRIDDEN");
});
Div reloadButton = new Div();
reloadButton.setId("reload");
reloadButton.setText("Reloads the page");
reloadButton.addClickListener(e -> {
getPage().reload();
});
add(input, updateButton, overrideButton, reloadButton);
}
Aggregations