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

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

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

Element.setInnerSafeHtml介绍

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

代码示例

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

  1. @Override
  2. protected void doHtmlImpl(SafeHtml html) {
  3. getCurrentElement().setInnerSafeHtml(html);
  4. }

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

  1. /**
  2. * Convenience method to convert the specified HTML into DOM elements and
  3. * return the parent of the DOM elements.
  4. *
  5. * @param html the HTML to convert
  6. * @param tmpElem a temporary element
  7. * @return the parent element
  8. */
  9. static Element convertToElements(Widget widget, Element tmpElem, SafeHtml html) {
  10. // Attach an event listener so we can catch synchronous load events from
  11. // cached images.
  12. DOM.setEventListener(tmpElem, widget);
  13. tmpElem.setInnerSafeHtml(html);
  14. // Detach the event listener.
  15. DOM.setEventListener(tmpElem, null);
  16. return tmpElem;
  17. }

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

  1. public void setValue(Context context, Element parent, C value) {
  2. SafeHtmlBuilder sb = new SafeHtmlBuilder();
  3. render(context, value, sb);
  4. parent.setInnerSafeHtml(sb.toSafeHtml());
  5. }

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

  1. @Override
  2. protected Element doFinishImpl() {
  3. Element tmp = Document.get().createDivElement();
  4. tmp.setInnerSafeHtml(asSafeHtml());
  5. return tmp.getFirstChildElement();
  6. }

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

  1. tmpElem.setInnerSafeHtml(template.tbody(rowHtml));
  2. } else if ("thead".equals(sectionTag)) {
  3. tmpElem.setInnerSafeHtml(template.thead(rowHtml));
  4. } else if ("tfoot".equals(sectionTag)) {
  5. tmpElem.setInnerSafeHtml(template.tfoot(rowHtml));
  6. } else {
  7. throw new IllegalArgumentException("Invalid table section tag: " + sectionTag);

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

  1. private void createFrame() {
  2. // Attach a hidden IFrame to the form. This is the target iframe to which
  3. // the form will be submitted. We have to create the iframe using innerHTML,
  4. // because setting an iframe's 'name' property dynamically doesn't work on
  5. // most browsers.
  6. Element dummy = Document.get().createDivElement();
  7. dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName));
  8. synthesizedFrame = dummy.getFirstChildElement();
  9. }

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

  1. /**
  2. * Creates an HTML IFRAME element with a name.
  3. *
  4. * @param name the name of the frame, which must contain at least one
  5. * non-whitespace character and must not contain reserved HTML markup
  6. * characters such as '<code>&lt;</code>', '<code>&gt;</code>',
  7. * or '<code>&amp;</code>'
  8. * @return the newly-created element
  9. * @throws IllegalArgumentException if the supplied name is not allowed
  10. */
  11. private static IFrameElement createIFrame(String name) {
  12. if (name == null || !isValidName(name.trim())) {
  13. throw new IllegalArgumentException(
  14. "expecting one or more non-whitespace chars with no '<', '>', or '&'");
  15. }
  16. // Use innerHTML to implicitly create the <iframe>. This is necessary
  17. // because most browsers will not respect a dynamically-set iframe name.
  18. Element div = DOM.createDiv();
  19. div.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(name));
  20. return div.getFirstChild().cast();
  21. }

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

  1. public Element createStructure(SafeUri url, int left, int top, int width, int height) {
  2. Element tmp = Document.get().createSpanElement();
  3. tmp.setInnerSafeHtml(getSafeHtml(url, left, top, width, height));
  4. Element elem = tmp.getFirstChildElement();
  5. elem.setPropertyJSO("onload", createOnLoadHandlerFunction());
  6. return elem;
  7. }

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

  1. /**
  2. * Convenience method to replace all children of a Widget.
  3. *
  4. * @param widget the widget who's contents will be replaced
  5. * @param childContainer the container that holds the contents
  6. * @param html the html to set
  7. */
  8. static void replaceAllChildren(Widget widget, Element childContainer, SafeHtml html) {
  9. // If the widget is not attached, attach an event listener so we can catch
  10. // synchronous load events from cached images.
  11. if (!widget.isAttached()) {
  12. DOM.setEventListener(widget.getElement(), widget);
  13. }
  14. // Render the HTML.
  15. childContainer.setInnerSafeHtml(CellBasedWidgetImpl.get().processHtml(html));
  16. // Detach the event listener.
  17. if (!widget.isAttached()) {
  18. DOM.setEventListener(widget.getElement(), null);
  19. }
  20. }

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

  1. @Override
  2. public void onBrowserEvent(Context context, Element parent, String value,
  3. NativeEvent event, ValueUpdater<String> valueUpdater) {
  4. // The loading indicator can fire its own load or error event, so we check
  5. // that the event actually occurred on the main image.
  6. String type = event.getType();
  7. if (BrowserEvents.LOAD.equals(type) && eventOccurredOnImage(event, parent)) {
  8. // Remove the loading indicator.
  9. parent.getFirstChildElement().getStyle().setDisplay(Display.NONE);
  10. // Show the image.
  11. Element imgWrapper = parent.getChild(1).cast();
  12. imgWrapper.getStyle().setProperty("height", "auto");
  13. imgWrapper.getStyle().setProperty("width", "auto");
  14. imgWrapper.getStyle().setProperty("overflow", "auto");
  15. } else if (BrowserEvents.ERROR.equals(type) && eventOccurredOnImage(event, parent)) {
  16. // Replace the loading indicator with an error message.
  17. parent.getFirstChildElement().setInnerSafeHtml(errorRenderer.render(value));
  18. }
  19. }

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

  1. Element td = DOM.createTD();
  2. td.setPropertyString("vAlign", "middle");
  3. td.setInnerSafeHtml(subMenuIcon.getSafeHtml());
  4. setStyleName(td, "subMenuIcon");
  5. DOM.appendChild(tr, td);

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

  1. element.setInnerSafeHtml(getInnerHtml());

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

  1. @Override
  2. protected void setKeyboardSelected(int index, boolean selected, boolean stealFocus) {
  3. super.setKeyboardSelected(index, selected, stealFocus);
  4. if (!isRowWithinBounds(index)) {
  5. return;
  6. }
  7. // Update the style.
  8. Element elem = getRowElement(index);
  9. T value = getPresenter().getVisibleItem(index);
  10. boolean isOpen = selected && isOpen(index);
  11. setStyleName(elem, style.cellBrowserOpenItem(), isOpen);
  12. // Update the image.
  13. SafeHtml image = null;
  14. if (isOpen) {
  15. image = openImageHtml;
  16. } else if (getTreeViewModel().isLeaf(value)) {
  17. image = LEAF_IMAGE;
  18. } else {
  19. image = closedImageHtml;
  20. }
  21. tmpElem.setInnerSafeHtml(image);
  22. elem.replaceChild(tmpElem.getFirstChildElement(), elem.getFirstChildElement());
  23. // Update the open state.
  24. updateChildState(this, true);
  25. }

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

  1. private void buildDOM(AbstractImagePrototype thumbImage) {
  2. final Element leftDiv = getElement(LEFT);
  3. final Element rightDiv = getElement(RIGHT);
  4. final Element splitDiv = getSplitElement();
  5. DOM.appendChild(getElement(), container);
  6. DOM.appendChild(container, leftDiv);
  7. DOM.appendChild(container, splitDiv);
  8. DOM.appendChild(container, rightDiv);
  9. /*
  10. * Sadly, this is the only way I've found to get vertical centering in this
  11. * case. The usually CSS hacks (display: table-cell, vertical-align: middle)
  12. * don't work in an absolute positioned DIV.
  13. */
  14. SafeHtmlBuilder sb = new SafeHtmlBuilder();
  15. sb.appendHtmlConstant("<table class='hsplitter' height='100%' cellpadding='0' "
  16. + "cellspacing='0'><tr><td align='center' valign='middle'>");
  17. sb.append(thumbImage.getSafeHtml());
  18. splitDiv.setInnerSafeHtml(sb.toSafeHtml());
  19. addScrolling(leftDiv);
  20. addScrolling(rightDiv);
  21. }

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

  1. @Override
  2. protected void doHtmlImpl(SafeHtml html) {
  3. getCurrentElement().setInnerSafeHtml(html);
  4. }

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

  1. private void buildDOM(AbstractImagePrototype thumb) {
  2. final Element topDiv = getElement(TOP);
  3. final Element bottomDiv = getElement(BOTTOM);
  4. final Element splitDiv = getSplitElement();
  5. DOM.appendChild(getElement(), container);
  6. DOM.appendChild(container, topDiv);
  7. DOM.appendChild(container, splitDiv);
  8. DOM.appendChild(container, bottomDiv);
  9. /*
  10. * The style name is placed on the table rather than splitElem to allow the
  11. * splitter to be styled without interfering with layout.
  12. */
  13. SafeHtmlBuilder sb = new SafeHtmlBuilder();
  14. sb.appendHtmlConstant("<div class='vsplitter' style='text-align:center;'>");
  15. sb.append(thumb.getSafeHtml());
  16. sb.appendHtmlConstant("</div>");
  17. splitDiv.setInnerSafeHtml(sb.toSafeHtml());
  18. addScrolling(topDiv);
  19. addScrolling(bottomDiv);
  20. }
  21. }

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

  1. tmp.setInnerSafeHtml(html);
  2. Element imageElem = tmp.getFirstChildElement();

代码示例来源:origin: net.wetheinter/gwt-user

  1. public Element createStructure(SafeUri url, int left, int top, int width, int height) {
  2. Element tmp = Document.get().createSpanElement();
  3. tmp.setInnerSafeHtml(getSafeHtml(url, left, top, width, height));
  4. return tmp.getFirstChildElement();
  5. }

代码示例来源:origin: gwtbootstrap3/gwtbootstrap3

  1. private void createFrame() {
  2. // Attach a hidden IFrame to the form. This is the target iframe to
  3. // which the form will be submitted. We have to create the iframe using
  4. // innerHTML, because setting an iframe's 'name' property dynamically
  5. // doesn't work on most browsers.
  6. Element dummy = Document.get().createDivElement();
  7. dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName));
  8. synthesizedFrame = dummy.getFirstChildElement();
  9. }

代码示例来源:origin: org.gwtbootstrap3/gwtbootstrap3

  1. private void createFrame() {
  2. // Attach a hidden IFrame to the form. This is the target iframe to
  3. // which the form will be submitted. We have to create the iframe using
  4. // innerHTML, because setting an iframe's 'name' property dynamically
  5. // doesn't work on most browsers.
  6. Element dummy = Document.get().createDivElement();
  7. dummy.setInnerSafeHtml(IFrameTemplate.INSTANCE.get(frameName));
  8. synthesizedFrame = dummy.getFirstChildElement();
  9. }

相关文章

Element类方法