Search in sources :

Example 1 with Input

use of com.vaadin.flow.component.html.Input in project flow by vaadin.

the class BasicComponentView method onShow.

@Override
protected void onShow() {
    getElement().getStyle().set("margin", "1em");
    getElement().setAttribute("id", "root");
    Text text = new Text(TEXT);
    Input input = new Input();
    input.setPlaceholder("Synchronized on change event");
    NativeButton button = new NativeButton(BUTTON_TEXT, e -> {
        Div greeting = new Div();
        greeting.addClassName("thankYou");
        String buttonText = e.getSource().getElement().getText();
        greeting.setText("Thank you for clicking \"" + buttonText + "\" at (" + e.getClientX() + "," + e.getClientY() + ")! The field value is " + input.getValue());
        greeting.addClickListener(e2 -> remove(greeting));
        add(greeting);
    });
    Div helloWorld = new Div();
    helloWorld.setText(DIV_TEXT);
    helloWorld.addClassName("hello");
    helloWorld.setId("hello-world");
    helloWorld.addClickListener(e -> {
        helloWorld.setText("Stop touching me!");
        helloWorld.getElement().getClassList().clear();
    });
    Style s = helloWorld.getElement().getStyle();
    s.set("color", "red");
    s.set("fontWeight", "bold");
    add(text, helloWorld, button, input);
}
Also used : Div(com.vaadin.flow.component.html.Div) NativeButton(com.vaadin.flow.component.html.NativeButton) Input(com.vaadin.flow.component.html.Input) Style(com.vaadin.flow.dom.Style) Text(com.vaadin.flow.component.Text)

Example 2 with Input

use of com.vaadin.flow.component.html.Input in project flow by vaadin.

the class ExecJavaScriptView method onShow.

@Override
protected void onShow() {
    NativeButton alertButton = createJsButton("Alert", "alertButton", "window.alert($0)", "Hello world");
    NativeButton focusButton = createJsButton("Focus Alert button", "focusButton", "$0.focus()", alertButton);
    NativeButton swapText = createJsButton("Swap button texts", "swapButton", "(function() {var t = $0.textContent; $0.textContent = $1.textContent; $1.textContent = t;})()", alertButton, focusButton);
    NativeButton logButton = createJsButton("Log", "logButton", "console.log($0)", JsonUtils.createArray(Json.create("Hello world"), Json.create(true)));
    NativeButton createElementButton = new NativeButton("Create and update element", e -> {
        Input input = new Input();
        input.addClassName("newInput");
        UI.getCurrent().getPage().executeJavaScript("$0.value = $1", input, "Value from js");
        add(input);
    });
    createElementButton.setId("createButton");
    add(alertButton, focusButton, swapText, logButton, createElementButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Input(com.vaadin.flow.component.html.Input)

Example 3 with Input

use of com.vaadin.flow.component.html.Input 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)

Example 4 with Input

use of com.vaadin.flow.component.html.Input in project flow by vaadin.

the class RPCLoggerUI method init.

@Override
protected void init(VaadinRequest request) {
    NativeButton button = new NativeButton("Click Me");
    button.addClickListener(event -> {
    });
    Input input = new Input();
    add(button, input);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Input(com.vaadin.flow.component.html.Input)

Aggregations

Input (com.vaadin.flow.component.html.Input)4 NativeButton (com.vaadin.flow.component.html.NativeButton)3 Div (com.vaadin.flow.component.html.Div)2 Text (com.vaadin.flow.component.Text)1 Style (com.vaadin.flow.dom.Style)1