Simon Kitching 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.
That's a good point. I'd probably still elect to render resources which
aren't actually required than to use a filter though.
A possible solution might be to have the resources component (which is
added the head component) inherit the 'required' attribute of the main
component. This behaviour could possibly be overridden by a
'resourcesRequired' attribute on the main component.
It wouldn't be too hard to come up with use cases where this wouldn't
work perfectly, but I reckon it'd cover the most common scenarios.
Roger
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
--
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: [EMAIL PROTECTED]
----------------------------------------