public void encodeMarkers(ResponseWriter writer, Theme theme, ClientDescriptor client) throws IOException { writer.startElement("script", null); writer.writeAttribute("type", "text/javascript", null); String markers = " " + theme.fileName(); // + " ui-mobile"; if (client.isIE10Browser()) { markers += " ie10"; } else if (client.isIE10orHigherBrowser()) { markers += " ie11"; } if (client.isAndroidOS()) { markers += " android"; } if (client.isAndroidBrowserOrWebView()) { markers += " android-browser"; } if (client.isDesktopBrowser()) { markers += " desktop"; } if (client.isSimulator()) { markers += " simulator"; } writer.writeText( "document.documentElement.className = document.documentElement.className+'" + markers + "';", null); writer.endElement("script"); }
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException { // http://javaserverfaces.java.net/nonav/docs/2.0/pdldocs/facelets/index.html // Finally make sure the component is only rendered in the header of the // HTML document. UIComponent component = event.getComponent(); FacesContext context = FacesContext.getCurrentInstance(); if (log.isLoggable(Level.FINER)) { log.finer("processEvent for component = " + component.getClass().getName()); } context.getViewRoot().addComponentResource(context, component, HTML.HEAD_ELEM); ClientDescriptor client = ClientDescriptor.getInstance( (HttpServletRequest) context.getExternalContext().getRequest()); String themeParam = context.getExternalContext().getRequestParameterMap().get("theme"); Theme theme = null; if (client.isIE9orLessBrowser()) { theme = Theme.ARCHAIC; } else { theme = Theme.getEnum( themeParam != null ? themeParam : (String) event.getComponent().getAttributes().get("theme")); if (theme == null) { String targetView = (String) event.getComponent().getAttributes().get("view"); theme = CSSUtils.deriveTheme(targetView, JSFUtils.getRequest()); } } // android and honeycomb themes deprecated if (theme == Theme.ANDROID || theme == Theme.HONEYCOMB) { theme = Theme.ANDROID_DARK; } context.getExternalContext().getSessionMap().put(MOBI_THEME_KEY, theme); }