示例#1
0
  /** Removes all CSS files dynamically added with {@link #addCss(String)}.<br> */
  private void removeDynamicCss() {
    Element eHead = XDOM.getDocument().getElementsByTagName(TAG_HEAD).getItem(0);

    for (Map.Entry<String, Element> e : additionalCss.entrySet()) {
      eHead.removeChild(e.getValue());
    }
  }
示例#2
0
  /**
   * Dynamically adds the passed CSS to the document, and stores in {@link #additionalCss} the
   * resulting <code>&lt;link rel="stylesheet"&gt;</code><br>
   *
   * @param css
   */
  private void addCss(StylesheetDTO css) {

    String id = Integer.valueOf(Random.nextInt()).toString();

    Element eLink = DOM.createElement(TAG_LINK);
    eLink.setAttribute(ATTRIBUTE_ID, id);
    eLink.setAttribute(ATTRIBUTE_REL, "stylesheet");
    eLink.setAttribute(ATTRIBUTE_TYPE, "text/css");
    eLink.setAttribute(ATTRIBUTE_HREF, css.getUrl());
    if (css.getMedia() != null) {
      eLink.setAttribute(ATTRIBUTE_MEDIA, css.getMedia());
    }

    Element eHead = XDOM.getDocument().getElementsByTagName(TAG_HEAD).getItem(0);
    eHead.appendChild(eLink);

    additionalCss.put(id, eLink);
  };