You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Simon Kitching <si...@chello.at> on 2007/11/22 13:38:07 UTC

Tomahawk ExtensionsFilter, Trinidad skinning

Hi All,

Tomahawk's ExtensionsFilter allows components to cause data to be inserted into the HEAD section of a generated HTML page, even when they occur in the body. In particular, this allows components to output references to javascript and css that they need. This is extremely useful, but the implementation is rather ugly.

I know almost nothing about Trinidad, but it presumably has something similar, in order to provide default skins for its components. Would someone be kind enough to give a very brief summary of how Trinidad achieves this? I'm hoping that there is something there I can steal to improve Tomahawk's approach.

Currently, tomahawk ExtensionFilter's standard approach is to buffer the entire output. As each component renders itself, it can register resources it needs in a request-scoped variable. After rendering is complete, the ExtensionFilter scans the buffered output for the closing </head> tag and similar bits, and inserts and registered resources into the buffer. This is inefficient due to the buffering, and the code is complex (a simple HTML parser is needed!).

Thanks,

Simon

Re: Tomahawk ExtensionsFilter, Trinidad skinning

Posted by Matthias Wessendorf <ma...@apache.org>.
Hi Simon,

usually you use <tr:document> (or <trh:html>, <trh:head>, <trh:body>).
The TrDocument uses the HeadRender to render something like this:

<link rel="stylesheet" charset="UTF-8" type="text/css"
href="/trinidad/adf/styles/cache/minimal-desktop-ne8suk-en-gecko-cmp.css">

the truth is here, that HeadREnderer uses the StyleSheetRenderer
(accessable via <trh:styleSheet> as well) to render the lines above.

The StyleSheetRenderer get's the URL (like here to the cache-folder)
via a StyleProvider implementation.

HTH,
Matthias

On Nov 22, 2007 1:38 PM, Simon Kitching <si...@chello.at> wrote:
> Hi All,
>
> Tomahawk's ExtensionsFilter allows components to cause data to be inserted into the HEAD section of a generated HTML page, even when they occur in the body. In particular, this allows components to output references to javascript and css that they need. This is extremely useful, but the implementation is rather ugly.
>
> I know almost nothing about Trinidad, but it presumably has something similar, in order to provide default skins for its components. Would someone be kind enough to give a very brief summary of how Trinidad achieves this? I'm hoping that there is something there I can steal to improve Tomahawk's approach.
>
> Currently, tomahawk ExtensionFilter's standard approach is to buffer the entire output. As each component renders itself, it can register resources it needs in a request-scoped variable. After rendering is complete, the ExtensionFilter scans the buffered output for the closing </head> tag and similar bits, and inserts and registered resources into the buffer. This is inefficient due to the buffering, and the code is complex (a simple HTML parser is needed!).
>
> Thanks,
>
> Simon
>



-- 
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org