users@javaserverfaces-spec-public.java.net

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

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

In hindsight, that boolean is superfluous. Make it a mutable
Set<ResourceIdentifier> or Set<String> and just consider the presence in
the set as already rendered.

Cheers, B

On Wed, Mar 4, 2015 at 4:05 PM, Bauke Scholtz <balusc_at_gmail.com> wrote:

> 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
>