Java Code Examples for elemental.dom.Element#appendChild()
The following examples show how to use
elemental.dom.Element#appendChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java From vertxui with GNU General Public License v3.0 | 6 votes |
public Client() { Element body = document.getBody(); button = document.createElement("button"); button.setAttribute("id", "hello-button"); button.setTextContent("Click me"); button.setOnclick(this::clicked); body.appendChild(button); response = document.createElement("div"); body.appendChild(response); thinking = document.createElement("div"); thinking.setTextContent("The server waits as demonstration"); thinking.getStyle().setProperty("display", "none"); body.appendChild(thinking); }
Example 2
Source File: Elements.java From core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Closes the current container element. * * @throws IllegalStateException if there's no current element or if the closing element is no container. */ public Builder end() { assertCurrent(); if (level == 0) { throw new IllegalStateException("Unbalanced element hierarchy. Elements stack: " + dumpElements()); } List<ElementInfo> children = new ArrayList<>(); while (elements.peek().level == level) { children.add(elements.pop()); } Collections.reverse(children); if (!elements.peek().container) { throw new IllegalStateException("Closing element " + elements.peek().element + " is no container"); } Element closingElement = elements.peek().element; for (ElementInfo child : children) { closingElement.appendChild(child.element); } level--; return this; }
Example 3
Source File: Client.java From vertxui with GNU General Public License v3.0 | 5 votes |
private void responsed(String text) { console.log("received: " + text); button.removeAttribute("disabled"); Element responseElem = document.createElement("div"); responseElem.appendChild(document.createTextNode(text)); response.appendChild(responseElem); thinking.getStyle().setProperty("display", "none"); }
Example 4
Source File: GwtBasicElementBinderTest.java From flow with Apache License 2.0 | 5 votes |
private Element createAndAppendElementToShadowRoot(Element shadowRoot, String id, String tagName) { Element childShadowRootElement = Browser.getDocument() .createElement(tagName); childShadowRootElement.setId(id); shadowRoot.appendChild(childShadowRootElement); if (id != null) { JsonObject obj = Json.createObject(); WidgetUtil.setJsProperty(obj, id.toString(), childShadowRootElement); WidgetUtil.setJsProperty(element, "$", obj); } return childShadowRootElement; }
Example 5
Source File: HomepageModule.java From core with GNU Lesser General Public License v2.1 | 5 votes |
public HomepageModule(final String token, final String image, final String header, final String subHeader, final HomepageSection... sections) { // @formatter:off Elements.Builder builder = new Elements.Builder() .div().css("eap-home-col") .div().css("eap-home-module") .div().css("eap-home-module-icon") .add("img").attr("src", image) .end() .div().css("eap-home-module-container").rememberAs("container") .div().css("eap-home-module-header") .h(2).a().attr("href", "#" + token).textContent(header).end().end() .p().textContent(subHeader).end() .end() .end() .end() .end(); // @formatter:on if (sections != null) { Element container = builder.referenceFor("container"); for (HomepageSection section : sections) { container.appendChild(section.asElement()); } } this.root = builder.build(); }
Example 6
Source File: SystemErrorHandler.java From flow with Apache License 2.0 | 4 votes |
private Element handleError(String caption, String message, String details, String querySelector) { Document document = Browser.getDocument(); Element systemErrorContainer = document.createDivElement(); systemErrorContainer.setClassName("v-system-error"); if (caption != null) { Element captionDiv = document.createDivElement(); captionDiv.setClassName("caption"); captionDiv.setInnerHTML(caption); systemErrorContainer.appendChild(captionDiv); Console.error(caption); } if (message != null) { Element messageDiv = document.createDivElement(); messageDiv.setClassName("message"); messageDiv.setInnerHTML(message); systemErrorContainer.appendChild(messageDiv); Console.error(message); } if (details != null) { Element detailsDiv = document.createDivElement(); detailsDiv.setClassName("details"); detailsDiv.setInnerHTML(details); systemErrorContainer.appendChild(detailsDiv); Console.error(details); } if (querySelector != null) { Element baseElement = document.querySelector(querySelector); // if querySelector does not match an element on the page, the // error will not be displayed if (baseElement != null) { // if the baseElement has a shadow root, add the warning to // the shadow - otherwise add it to the baseElement findShadowRoot(baseElement).orElse(baseElement) .appendChild(systemErrorContainer); } } else { document.getBody().appendChild(systemErrorContainer); } return systemErrorContainer; }