com.google.gwt.dom.client.Element.setInnerHTML()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(280)

本文整理了Java中com.google.gwt.dom.client.Element.setInnerHTML()方法的一些代码示例,展示了Element.setInnerHTML()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setInnerHTML()方法的具体详情如下:
包路径:com.google.gwt.dom.client.Element
类名称:Element
方法名:setInnerHTML

Element.setInnerHTML介绍

[英]All of the markup and content within a given element.
[中]给定元素中的所有标记和内容。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * All of the markup and content within a given element.
  3. */
  4. public final void setInnerSafeHtml(SafeHtml html) {
  5. setInnerHTML(html.asString());
  6. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Sets the HTML contained within an element.
  3. *
  4. * @param elem the element whose inner HTML is to be set
  5. * @param html the new html
  6. * @deprecated Use {@link Element#setInnerHTML(String)} instead.
  7. */
  8. @Deprecated
  9. public static void setInnerHTML(Element elem, @IsSafeHtml String html) {
  10. elem.setInnerHTML(html);
  11. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public void setHTML(@IsSafeHtml String html) {
  3. setWidget(null);
  4. contentElem.setInnerHTML(html);
  5. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. public final void setHTML(@IsSafeHtml String html) {
  3. if (beforeInitPlaceholder == null) {
  4. setHTMLImpl(html);
  5. } else {
  6. beforeInitPlaceholder.setInnerHTML(html);
  7. }
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. private void setInnerTextOrHtml(@IsSafeHtml String content, boolean isHtml) {
  2. if (isHtml) {
  3. element.setInnerHTML(content);
  4. } else {
  5. element.setInnerText(content);
  6. }
  7. }
  8. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Creates a new, empty cell.
  3. */
  4. @Override
  5. protected com.google.gwt.user.client.Element createCell() {
  6. Element td = super.createCell();
  7. // Add a non-breaking space to the TD. This ensures that the cell is
  8. // displayed.
  9. td.setInnerHTML(" ");
  10. return DOM.asOld(td);
  11. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Replaces the contents of the specified cell with a single space.
  3. *
  4. * @param row the cell's row
  5. * @param column the cell's column
  6. * @throws IndexOutOfBoundsException
  7. */
  8. @Override
  9. public boolean clearCell(int row, int column) {
  10. Element td = getCellFormatter().getElement(row, column);
  11. boolean b = internalClearCell(td, false);
  12. td.setInnerHTML(" ");
  13. return b;
  14. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Sets the HTML contents of the specified cell.
  3. *
  4. * @param row the cell's row
  5. * @param column the cell's column
  6. * @param html the cell's HTML contents
  7. * @throws IndexOutOfBoundsException
  8. */
  9. public void setHTML(int row, int column, @IsSafeHtml String html) {
  10. prepareCell(row, column);
  11. Element td = cleanCell(row, column, html == null);
  12. if (html != null) {
  13. td.setInnerHTML(html);
  14. }
  15. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. public static Element fromHtml(@IsSafeHtml String html) {
  2. ensureHiddenDiv();
  3. hiddenDiv.setInnerHTML(html);
  4. Element newbie = hiddenDiv.getFirstChildElement();
  5. orphan(newbie);
  6. return newbie;
  7. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Set the face's contents as html.
  3. *
  4. * @param html html to set as face's contents html
  5. *
  6. */
  7. @Override
  8. public void setHTML(@IsSafeHtml String html) {
  9. face = DOM.createDiv();
  10. UIObject.setStyleName(face, STYLENAME_HTML_FACE, true);
  11. face.setInnerHTML(html);
  12. updateButtonFace();
  13. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. @SuppressIsSafeHtmlCastCheck
  3. public Element createElement(Document doc, String tagName) {
  4. if (tagName.contains(":")) {
  5. // Special implementation for tag names with namespace-prefixes. The only
  6. // way to get IE to reliably create namespace-prefixed elements is
  7. // through innerHTML.
  8. Element container = ensureContainer(doc);
  9. container.setInnerHTML("<" + tagName + "/>");
  10. // Remove the element before returning it, so that there's no chance of
  11. // it getting clobbered later.
  12. Element elem = container.getFirstChildElement();
  13. container.removeChild(elem);
  14. return elem;
  15. }
  16. // No prefix. Just use the default implementation (don't use super impl
  17. // here in case it changes at some point in the future).
  18. return createElementInternal(doc, tagName);
  19. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. outerElem.setInnerHTML("<div></div>");

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. public void setCaption(
  2. FieldSetElement fieldset, Element legend, @IsSafeHtml String caption, boolean asHTML) {
  3. // TODO(bruce): rewrite to be inlinable
  4. assert (caption != null);
  5. if (asHTML) {
  6. legend.setInnerHTML(caption);
  7. } else {
  8. legend.setInnerText(caption);
  9. }
  10. if (!"".equals(caption)) {
  11. // This is formulated to become an append (if there's no widget), an
  12. // insertion at index 0 (if there is a widget but no legend already), or
  13. // a no-op (if the legend is already in place).
  14. fieldset.insertBefore(legend, fieldset.getFirstChild());
  15. } else if (legend.getParentNode() != null) {
  16. // We remove the legend from the DOM because leaving it in with an empty
  17. // string renders as an ugly gap in the top border on some browsers.
  18. fieldset.removeChild(legend);
  19. }
  20. }
  21. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Sets the element's content to the given value (either plain text or HTML),
  3. * applying the given direction. Prefer using
  4. * {@link #setText(String, com.google.gwt.i18n.client.HasDirection.Direction) setText} or
  5. * {@link #setHtml(String, com.google.gwt.i18n.client.HasDirection.Direction) setHtml}
  6. * instead of this method.
  7. *
  8. * @param content the element's new content
  9. * @param dir the content's direction
  10. * @param isHtml whether the content is HTML
  11. */
  12. public void setTextOrHtml(@IsSafeHtml String content, Direction dir, boolean isHtml) {
  13. textDir = dir;
  14. // Set the text and the direction.
  15. if (isElementInline) {
  16. isSpanWrapped = true;
  17. element.setInnerHTML(BidiFormatter.getInstanceForCurrentLocale(
  18. true /* alwaysSpan */).spanWrapWithKnownDir(dir, content, isHtml));
  19. } else {
  20. isSpanWrapped = false;
  21. BidiUtils.setDirectionOnElement(element, dir);
  22. setInnerTextOrHtml(content, isHtml);
  23. }
  24. isDirectionExplicitlySet = true;
  25. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Put the node back into a clean state and clear fields.
  3. */
  4. private void cleanup() {
  5. if (opening) {
  6. animFrame.getStyle().clearDisplay();
  7. } else {
  8. animFrame.getStyle().setDisplay(Display.NONE);
  9. childContainer.setInnerHTML("");
  10. }
  11. animFrame.getStyle().clearHeight();
  12. animFrame.getStyle().clearPosition();
  13. this.contentContainer = null;
  14. this.childContainer = null;
  15. this.animFrame = null;
  16. }
  17. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. @Override
  2. @SuppressIsSafeHtmlCastCheck
  3. public void uninitElement() {
  4. isReady = false;
  5. // Issue 1897: initElement uses a timeout, so its possible to call this
  6. // method after calling initElement, but before the event system is in
  7. // place.
  8. if (initializing) {
  9. initializing = false;
  10. return;
  11. }
  12. // Unhook all custom event handlers when the element is detached.
  13. unhookEvents();
  14. // Recreate the placeholder element and store the iframe's contents and the
  15. // enabled status in it. This is necessary because some browsers will wipe
  16. // the iframe's contents when it is removed from the DOM.
  17. @IsSafeHtml String html = getHTML(); // TODO: mXSS
  18. boolean enabled = isEnabled();
  19. beforeInitPlaceholder = DOM.createDiv();
  20. beforeInitPlaceholder.setInnerHTML(html);
  21. setEnabled(enabled);
  22. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. /**
  2. * Sets the text associated with a child by its index.
  3. *
  4. * @param index the index of the child whose text is to be set
  5. * @param text the text to be associated with it
  6. * @param asHTML <code>true</code> to treat the specified text as HTML
  7. */
  8. public void setStackText(int index, @IsSafeHtml String text, boolean asHTML) {
  9. if (index >= getWidgetCount()) {
  10. return;
  11. }
  12. Element tdWrapper = DOM.getChild(DOM.getChild(body, index * 2), 0);
  13. Element headerElem = DOM.getFirstChild(tdWrapper);
  14. if (asHTML) {
  15. getHeaderTextElem(headerElem).setInnerHTML(text);
  16. } else {
  17. getHeaderTextElem(headerElem).setInnerText(text);
  18. }
  19. }

代码示例来源:origin: com.google.gwt/gwt-servlet

  1. contentElem.setInnerHTML("");

代码示例来源:origin: org.uberfire/uberfire-preferences-ui-client

  1. @Override
  2. public void init(final TreeHierarchyInternalItemPresenter presenter) {
  3. this.presenter = presenter;
  4. final String preferenceLabel = getPreferenceLabel(presenter.getHierarchyElement().getBundleKey());
  5. label.setInnerHTML(preferenceLabel);
  6. treeNode.getStyle().setProperty("padding-left",
  7. presenter.getLevel() * 27 + 8 + "px");
  8. presenter.getHierarchyItems().forEach(hierarchyItem -> {
  9. children.appendChild(((IsElement) hierarchyItem.getView()).getElement());
  10. });
  11. }

代码示例来源:origin: GwtMaterialDesign/gwt-material

  1. public void testToastWithStyling() {
  2. MaterialToast.fireToast("test", "rounded");
  3. Element toastContainer = $("body").find("#toast-container").asElement();
  4. assertNotNull(toastContainer);
  5. assertEquals(toastContainer.getChildCount(), 1);
  6. assertNotNull(toastContainer.getChild(0));
  7. assertTrue(toastContainer.getChild(0) instanceof Element);
  8. Element toastElement = (Element) toastContainer.getChild(0);
  9. assertTrue(toastElement.hasClassName("rounded"));
  10. toastContainer.setInnerHTML("");
  11. }

相关文章

Element类方法