Search in sources :

Example 6 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ComponentRenderer method setupTemplateWhenAttached.

private void setupTemplateWhenAttached(UI ui, Element owner, ComponentRendering rendering, DataKeyMapper<SOURCE> keyMapper) {
    String appId = ui.getInternals().getAppId();
    Element templateElement = rendering.getTemplateElement();
    owner.appendChild(templateElement);
    Element container = new Element("div", false);
    owner.appendVirtualChild(container);
    rendering.setContainer(container);
    String templateInnerHtml;
    if (keyMapper != null) {
        String nodeIdPropertyName = "_renderer_" + templateElement.getNode().getId();
        templateInnerHtml = String.format("<%s appid=\"%s\" nodeid=\"[[item.%s]]\"></%s>", componentRendererTag, appId, nodeIdPropertyName, componentRendererTag);
        rendering.setNodeIdPropertyName(nodeIdPropertyName);
    } else {
        COMPONENT component = createComponent(null);
        if (component != null) {
            container.appendChild(component.getElement());
            templateInnerHtml = String.format("<%s appid=\"%s\" nodeid=\"%s\"></%s>", componentRendererTag, appId, component.getElement().getNode().getId(), componentRendererTag);
        } else {
            templateInnerHtml = "";
        }
    }
    templateElement.setProperty("innerHTML", templateInnerHtml);
}
Also used : Element(com.vaadin.flow.dom.Element)

Example 7 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class ElementStyleView method onShow.

@Override
protected void onShow() {
    Element mainElement = getElement();
    mainElement.getStyle().set("--foo", RED_BORDER);
    Div div = new Div();
    div.setId("red-border");
    div.getElement().getStyle().set("border", "var(--foo)");
    div.setText("Div");
    Div div2 = new Div();
    div2.setId("green-border");
    div2.setText("Div 2");
    div2.getStyle().set("--foo", GREEN_BORDER);
    div2.getElement().getStyle().set("border", "var(--foo)");
    add(div, div2);
}
Also used : Div(com.vaadin.flow.component.html.Div) Element(com.vaadin.flow.dom.Element)

Example 8 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class HistoryView method addStatus.

private void addStatus(String text) {
    Element statusRow = addRow(Element.createText(text));
    statusRow.getClassList().add("status");
}
Also used : Element(com.vaadin.flow.dom.Element)

Example 9 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class NavigationTriggerView method addMessage.

private void addMessage(String message) {
    Element element = ElementFactory.createDiv(message);
    element.getClassList().add("message");
    getElement().appendChild(element);
}
Also used : Element(com.vaadin.flow.dom.Element)

Example 10 with Element

use of com.vaadin.flow.dom.Element in project flow by vaadin.

the class SynchronizedPropertyView method addSyncMultipleProperties.

private void addSyncMultipleProperties() {
    add(new Text("Synchronize 'value' on 'input' event and 'valueAsNumber' on 'blur'"));
    Div valueLabel = new Div();
    valueLabel.setId("multiSyncValueLabel");
    Div valueAsNumberLabel = new Div();
    valueAsNumberLabel.setId("multiSyncValueAsNumberLabel");
    Element multiSync = ElementFactory.createInput("number");
    multiSync.setAttribute("id", "multiSyncValue");
    multiSync.synchronizeProperty("valueAsNumber", "blur");
    multiSync.synchronizeProperty("value", "input");
    multiSync.addEventListener("input", e -> {
        valueLabel.setText("Server value: " + multiSync.getProperty("value"));
    });
    multiSync.addEventListener("blur", e -> {
        valueAsNumberLabel.setText("Server valueAsNumber: " + multiSync.getProperty("valueAsNumber"));
    });
    getElement().appendChild(multiSync);
    add(valueLabel, valueAsNumberLabel);
}
Also used : Div(com.vaadin.flow.component.html.Div) Element(com.vaadin.flow.dom.Element) Text(com.vaadin.flow.component.Text)

Aggregations

Element (com.vaadin.flow.dom.Element)377 Test (org.junit.Test)322 UI (com.vaadin.flow.component.UI)42 StateNode (com.vaadin.flow.internal.StateNode)32 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)29 Style (com.vaadin.flow.dom.Style)25 StreamResource (com.vaadin.flow.server.StreamResource)20 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)19 ArrayList (java.util.ArrayList)14 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)13 JsonObject (elemental.json.JsonObject)12 WeakReference (java.lang.ref.WeakReference)12 URI (java.net.URI)11 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)10 Registration (com.vaadin.flow.shared.Registration)10 JsonValue (elemental.json.JsonValue)10 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)8 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)8