Search in sources :

Example 1 with Node

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

the class AbstractNodeStateProvider method attachExistingElement.

@Override
public void attachExistingElement(StateNode node, String tagName, Element previousSibling, ChildElementConsumer callback) {
    if (tagName == null) {
        throw new IllegalArgumentException("Tag name parameter cannot be null");
    }
    if (callback == null) {
        throw new IllegalArgumentException("Callback parameter cannot be null");
    }
    /*
         * create a node that should represent the client-side element. This
         * node won't be available anywhere and will be removed if there is no
         * appropriate element on the client-side. This node will be used after
         * client-side roundtrip for the appropriate element.
         */
    StateNode proposedNode = BasicElementStateProvider.createStateNode(tagName);
    node.runWhenAttached(ui -> ui.getInternals().getStateTree().beforeClientResponse(node, context -> {
        node.getFeature(AttachExistingElementFeature.class).register(getNode(node), previousSibling, proposedNode, callback);
        ui.getPage().executeJs("this.attachExistingElement($0, $1, $2, $3);", getNode(node), previousSibling, tagName, proposedNode.getId());
    }));
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) VirtualChildrenList(com.vaadin.flow.internal.nodefeature.VirtualChildrenList) ElementStateProvider(com.vaadin.flow.dom.ElementStateProvider) AttachExistingElementFeature(com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature) NodeVisitor(com.vaadin.flow.dom.NodeVisitor) ShadowRoot(com.vaadin.flow.dom.ShadowRoot) NodeFeature(com.vaadin.flow.internal.nodefeature.NodeFeature) Element(com.vaadin.flow.dom.Element) ElementChildrenList(com.vaadin.flow.internal.nodefeature.ElementChildrenList) Optional(java.util.Optional) ShadowRootHost(com.vaadin.flow.internal.nodefeature.ShadowRootHost) Node(com.vaadin.flow.dom.Node) ChildElementConsumer(com.vaadin.flow.dom.ChildElementConsumer) StateNode(com.vaadin.flow.internal.StateNode)

Aggregations

ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)1 Element (com.vaadin.flow.dom.Element)1 ElementStateProvider (com.vaadin.flow.dom.ElementStateProvider)1 Node (com.vaadin.flow.dom.Node)1 NodeVisitor (com.vaadin.flow.dom.NodeVisitor)1 ShadowRoot (com.vaadin.flow.dom.ShadowRoot)1 StateNode (com.vaadin.flow.internal.StateNode)1 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)1 ElementChildrenList (com.vaadin.flow.internal.nodefeature.ElementChildrenList)1 NodeFeature (com.vaadin.flow.internal.nodefeature.NodeFeature)1 ShadowRootHost (com.vaadin.flow.internal.nodefeature.ShadowRootHost)1 VirtualChildrenList (com.vaadin.flow.internal.nodefeature.VirtualChildrenList)1 Optional (java.util.Optional)1