// title
writer.startElement(HtmlElements.TITLE, null);
writer.writeText(title != null ? title : "");
writer.endElement(HtmlElements.TITLE);
final Theme theme = client.getTheme();
// style files
for (final String styleFile : theme.getStyleResources(productionMode)) {
writeStyle(facesContext, writer, styleFile);
}
for (final String styleFile : FacesContextUtils.getStyleFiles(facesContext)) {
writeStyle(facesContext, writer, styleFile);
}
if (!productionMode) {
checkDuplicates(theme.getStyleResources(productionMode), FacesContextUtils.getStyleFiles(facesContext));
}
final String icon = page.getApplicationIcon();
if (icon != null) {
final String href;
if (ResourceManagerUtils.isAbsoluteResource(icon)) {
href = icon;
} else {
href = ResourceManagerUtils.getImageWithPath(facesContext, icon);
}
if (href != null) {
writer.startElement(HtmlElements.LINK, null);
if (href.endsWith(".ico")) {
writer.writeAttribute(HtmlAttributes.REL, "shortcut icon", false);
writer.writeAttribute(HtmlAttributes.HREF, href, false);
} else {
// XXX IE only supports ICO files for favicons
writer.writeAttribute(HtmlAttributes.REL, "icon", false);
writer.writeAttribute(HtmlAttributes.TYPE, MimeTypeUtils.getMimeTypeForFile(href), false);
writer.writeAttribute(HtmlAttributes.HREF, href, false);
}
writer.endElement(HtmlElements.LINK);
} else {
LOG.warn("Application icon '" + icon + "' not found!");
}
}
// style sniplets
final Set<String> styleBlocks = FacesContextUtils.getStyleBlocks(facesContext);
if (styleBlocks.size() > 0) {
writer.startElement(HtmlElements.STYLE, null);
writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
for (final String cssBlock : styleBlocks) {
writer.write(cssBlock);
}
writer.endElement(HtmlElements.STYLE);
}
// render remaining script tags
for (final String scriptFile : theme.getScriptResources(productionMode)) {
encodeScript(facesContext, writer, scriptFile);
}
for (final String scriptFile : FacesContextUtils.getScriptFiles(facesContext)) {
encodeScript(facesContext, writer, scriptFile);
}
if (!productionMode) {
checkDuplicates(theme.getScriptResources(productionMode), FacesContextUtils.getScriptFiles(facesContext));
}
writer.startJavascript();
// onload script
writeEventFunction(writer, FacesContextUtils.getOnloadScripts(facesContext), "load", false);