jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Set and check component resource rendered via standard API

From: Bauke Scholtz <balusc_at_gmail.com>
Date: Wed, 4 Mar 2015 16:05:13 +0100

Hi,

Both Mojarra and MyFaces have an internal way to mark a script or
stylesheet resource as rendered (to avoid duplicate rendering). Mojarra
sets it as a context attribute with name+library as key and a boolean true
as value (see a.o. StylesheetRenderer#encodeEnd()). MyFaces sets it as a
context attribute via a Map<String, Boolean> (see a.o.
HtmlStylesheetRenderer#encodeEnd() via a ResourceUtils helper class).

For component library developers it would be very useful if this
information is available by standard API means so that the component
library can if necessary check and/or suppress the rendering of those
resources. For example to combine those resources via a special resource
handler, or to automatically delegate to a CDN host, or to turn a script
resource into a deferred script, etcetera.

I'd propose adding UIViewRoot#getRenderedComponentResources() which returns
a mutable Map<ResourceIdentifier, Boolean> for the purpose where
ResourceIdentifier could also be a String in the standard format
library+":"+name.

What do others think about it?

Cheers, B