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

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

本文整理了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

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

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

/**
 * Sets the HTML contained within an element.
 *
 * @param elem the element whose inner HTML is to be set
 * @param html the new html
 * @deprecated Use {@link Element#setInnerHTML(String)} instead.
 */
@Deprecated
public static void setInnerHTML(Element elem, @IsSafeHtml String html) {
 elem.setInnerHTML(html);
}

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

@Override
public void setHTML(@IsSafeHtml String html) {
 setWidget(null);
 contentElem.setInnerHTML(html);
}

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

@Override
public final void setHTML(@IsSafeHtml String html) {
 if (beforeInitPlaceholder == null) {
  setHTMLImpl(html);
 } else {
  beforeInitPlaceholder.setInnerHTML(html);
 }
}

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

private void setInnerTextOrHtml(@IsSafeHtml String content, boolean isHtml) {
  if (isHtml) {
   element.setInnerHTML(content);
  } else {
   element.setInnerText(content);
  }
 }
}

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

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

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

/**
 * Replaces the contents of the specified cell with a single space.
 * 
 * @param row the cell's row
 * @param column the cell's column
 * @throws IndexOutOfBoundsException
 */
@Override
public boolean clearCell(int row, int column) {
 Element td = getCellFormatter().getElement(row, column);
 boolean b = internalClearCell(td, false);
 td.setInnerHTML(" ");
 return b;
}

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

/**
 * Sets the HTML contents of the specified cell.
 *
 * @param row the cell's row
 * @param column the cell's column
 * @param html the cell's HTML contents
 * @throws IndexOutOfBoundsException
 */
public void setHTML(int row, int column, @IsSafeHtml String html) {
 prepareCell(row, column);
 Element td = cleanCell(row, column, html == null);
 if (html != null) {
  td.setInnerHTML(html);
 }
}

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

public static Element fromHtml(@IsSafeHtml String html) {
 ensureHiddenDiv();
 hiddenDiv.setInnerHTML(html);
 Element newbie = hiddenDiv.getFirstChildElement();
 orphan(newbie);
 return newbie;
}

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

/**
 * Set the face's contents as html.
 *
 * @param html html to set as face's contents html
 *
 */
@Override
public void setHTML(@IsSafeHtml String html) {
 face = DOM.createDiv();
 UIObject.setStyleName(face, STYLENAME_HTML_FACE, true);
 face.setInnerHTML(html);
 updateButtonFace();
}

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

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

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

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

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

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

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

/**
 * Sets the element's content to the given value (either plain text or HTML),
 * applying the given direction. Prefer using
 * {@link #setText(String, com.google.gwt.i18n.client.HasDirection.Direction) setText} or
 * {@link #setHtml(String, com.google.gwt.i18n.client.HasDirection.Direction) setHtml}
 * instead of this method.
 *
 * @param content the element's new content
 * @param dir the content's direction
 * @param isHtml whether the content is HTML
 */
public void setTextOrHtml(@IsSafeHtml String content, Direction dir, boolean isHtml) {
 textDir = dir;
 // Set the text and the direction.
 if (isElementInline) {
  isSpanWrapped = true;
  element.setInnerHTML(BidiFormatter.getInstanceForCurrentLocale(
    true /* alwaysSpan */).spanWrapWithKnownDir(dir, content, isHtml));
 } else {
  isSpanWrapped = false;
  BidiUtils.setDirectionOnElement(element, dir);
  setInnerTextOrHtml(content, isHtml);
 }
 isDirectionExplicitlySet = true;
}

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

/**
  * Put the node back into a clean state and clear fields.
  */
 private void cleanup() {
  if (opening) {
   animFrame.getStyle().clearDisplay();
  } else {
   animFrame.getStyle().setDisplay(Display.NONE);
   childContainer.setInnerHTML("");
  }
  animFrame.getStyle().clearHeight();
  animFrame.getStyle().clearPosition();
  this.contentContainer = null;
  this.childContainer = null;
  this.animFrame = null;
 }
}

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

@Override
@SuppressIsSafeHtmlCastCheck
public void uninitElement() {
 isReady = false;
 // Issue 1897: initElement uses a timeout, so its possible to call this
 // method after calling initElement, but before the event system is in
 // place.
 if (initializing) {
  initializing = false;
  return;
 }
 // Unhook all custom event handlers when the element is detached.
 unhookEvents();
 // Recreate the placeholder element and store the iframe's contents and the
 // enabled status in it. This is necessary because some browsers will wipe
 // the iframe's contents when it is removed from the DOM.
 @IsSafeHtml String html = getHTML(); // TODO: mXSS
 boolean enabled = isEnabled();
 beforeInitPlaceholder = DOM.createDiv();
 beforeInitPlaceholder.setInnerHTML(html);
 setEnabled(enabled);
}

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

/**
 * Sets the text associated with a child by its index.
 *
 * @param index the index of the child whose text is to be set
 * @param text the text to be associated with it
 * @param asHTML <code>true</code> to treat the specified text as HTML
 */
public void setStackText(int index, @IsSafeHtml String text, boolean asHTML) {
 if (index >= getWidgetCount()) {
  return;
 }
 Element tdWrapper = DOM.getChild(DOM.getChild(body, index * 2), 0);
 Element headerElem = DOM.getFirstChild(tdWrapper);
 if (asHTML) {
  getHeaderTextElem(headerElem).setInnerHTML(text);
 } else {
  getHeaderTextElem(headerElem).setInnerText(text);
 }
}

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

contentElem.setInnerHTML("");

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

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

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

public void testToastWithStyling() {
  MaterialToast.fireToast("test", "rounded");
  Element toastContainer = $("body").find("#toast-container").asElement();
  assertNotNull(toastContainer);
  assertEquals(toastContainer.getChildCount(), 1);
  assertNotNull(toastContainer.getChild(0));
  assertTrue(toastContainer.getChild(0) instanceof Element);
  Element toastElement = (Element) toastContainer.getChild(0);
  assertTrue(toastElement.hasClassName("rounded"));
  toastContainer.setInnerHTML("");
}

相关文章

微信公众号

最新文章

更多

Element类方法