Why couldn't all the components that need resources implement some
interface and then have the h:head component walk the component tree
looking for components implementing the interface?

On 3/22/07, Simon Kitching <[EMAIL PROTECTED]> wrote:
Mike Kienenberger wrote:
> Roger blogged,
>> With separate build and render phases, you could have a <h:head>
>> component which
>> other components could add resources to as they are created during the
>> tree build.
>
> Hmm.   I wonder if we could implement this for facelets/branch 1.2.

Probably not.

The point is that components don't know at the time they are *created*
whether they want to insert stuff into the head or not; they only know
that at *render* time. And by then the head tag has already rendered
itself. Well, unless we allow every component in the page to output its
required resources regardless of whether it is later rendered or not.

A head tag could be useful though; currently the ReducedHTMLParser is
needed to parse the page and find the <head> tag. It's not simply a
matter of looking for that string due to things like
   <!-- the <head> is not here -->
   <script>
     var s = "<head>";
   </script>
etc. However a head tag could output a unique marker like
   <!--HEAD12345567890-->
which could more easily be scanned for by the ExtensionsFilter. This
marker approach is already used for figuring out where to insert
serialized client state etc.


Items 1,2 and 3 of the blog are all issues that could be pretty easily
fixed in the ExtensionsFilter. Not that I'm claiming it's a great
solution, but a fixed ExtensionsFilter would be better than hand-coding
resources in the head section.

Cheers,

Simon

Reply via email to