Search in sources :

Example 16 with Div

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);
}
Also used : Div(com.vaadin.flow.component.html.Div) HasComponents(com.vaadin.flow.component.HasComponents) EventHandler(com.vaadin.flow.component.polymertemplate.EventHandler)

Example 17 with 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();"));
    }
}
Also used : Div(com.vaadin.flow.component.html.Div)

Example 18 with Div

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");
    });
}
Also used : Div(com.vaadin.flow.component.html.Div) Span(com.vaadin.flow.component.html.Span)

Example 19 with Div

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);
}
Also used : Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) Label(com.vaadin.flow.component.html.Label)

Example 20 with Div

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);
}
Also used : Div(com.vaadin.flow.component.html.Div) Input(com.vaadin.flow.component.html.Input)

Aggregations

Div (com.vaadin.flow.component.html.Div)30 NativeButton (com.vaadin.flow.component.html.NativeButton)7 Text (com.vaadin.flow.component.Text)6 Element (com.vaadin.flow.dom.Element)4 HasComponents (com.vaadin.flow.component.HasComponents)3 EventHandler (com.vaadin.flow.component.polymertemplate.EventHandler)3 Input (com.vaadin.flow.component.html.Input)2 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)2 HasText (com.vaadin.flow.component.HasText)1 H3 (com.vaadin.flow.component.html.H3)1 Hr (com.vaadin.flow.component.html.Hr)1 Label (com.vaadin.flow.component.html.Label)1 Span (com.vaadin.flow.component.html.Span)1 Style (com.vaadin.flow.dom.Style)1 NameField (com.vaadin.flow.uitest.ui.CompositeView.NameField)1