{
additionalQueryParams = resourceName.substring(index + 1);
resourceName = resourceName.substring(0, index);
}
Resource resource;
if (libraryName == null)
{
if (ResourceUtils.isRenderedStylesheet(facesContext, libraryName, resourceName))
{
//Resource already founded
return;
}
resource = facesContext.getApplication().getResourceHandler()
.createResource(resourceName);
}
else
{
if (ResourceUtils.isRenderedStylesheet(facesContext, libraryName, resourceName))
{
//Resource already founded
return;
}
resource = facesContext.getApplication().getResourceHandler()
.createResource(resourceName, libraryName);
}
if (resource == null)
{
//no resource found
log.warning("Resource referenced by resourceName "+ resourceName +
(libraryName == null ? "" : " and libraryName " + libraryName) +
" not found in call to ResourceHandler.createResource."+
" It will be silenty ignored.");
return;
}
else
{
if (ResourceUtils.isRenderedStylesheet(facesContext, resource.getLibraryName(), resource.getResourceName()))
{
//Resource already founded
return;
}
// Rendering resource
ResourceUtils.markStylesheetAsRendered(facesContext, libraryName, resourceName);
ResourceUtils.markStylesheetAsRendered(facesContext, resource.getLibraryName(), resource.getResourceName());
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.LINK_ELEM, component);
writer.writeAttribute(HTML.REL_ATTR, HTML.STYLESHEET_VALUE,null );
String media = (String) component.getAttributes().get("media");
writer.writeAttribute("media", media == null ? "screen" : media ,null );
writer.writeAttribute(HTML.TYPE_ATTR,
(resource.getContentType() == null ? HTML.STYLE_TYPE_TEXT_CSS
: resource.getContentType()) , null);
String path = resource.getRequestPath();
if (additionalQueryParams != null)
{
path = path + ((path.indexOf('?') >= 0) ? "&" : "?") + additionalQueryParams;
}
writer.writeURIAttribute(HTML.HREF_ATTR,