protected Class<? extends UIComponent> getComponentClass() {
return UIResource.class;
}
public void encodeToHead(FacesContext context, UIComponent component) throws IOException {
UIResource resource = (UIResource) component;
Object src = resource.getSrc();
if(null == src) {
throw new FacesException("Source for resource is null for component "+resource.getClientId(context));
}
String family = resource.getFamily();
ResourceRenderer renderer = null;
InternetResource internetResource = null;
Map<String, Object> attributes = Collections.emptyMap();
if (SCRIPT_COMPONENT_FAMILY.equals(family)) {
renderer = InternetResourceBuilder.getInstance().getScriptRenderer();
} else if (STYLE_COMPONENT_FAMILY.equals(family)) {
renderer = InternetResourceBuilder.getInstance().getStyleRenderer();
String media = (String) resource.getAttributes().get(HTML.media_ATTRIBUTE);
if (media != null && media.length() != 0) {
attributes = new HashMap<String, Object>();
attributes.put(HTML.media_ATTRIBUTE, media);
}
}
if (src instanceof InternetResource) {
internetResource = (InternetResource) src;
} else {
if(resource.isRendered()){
String uri = context.getApplication().getViewHandler().
getResourceURL(context, src.toString());
uri = context.getExternalContext().encodeResourceURL(uri);
internetResource = new URIInternetResource(uri);
}