/** 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()); } }
/** * Dynamically adds the passed CSS to the document, and stores in {@link #additionalCss} the * resulting <code><link rel="stylesheet"></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); };