Hi.

Has anyone integrated Weblets into MyFaces via the AddResource?

I'm writing my own components that rely on some js/css. Weblets seem to be a right thing to manage resources. Seems much easier to use and configure than MyFaces analogs.

At the same time I consider taking advantage of positioning resources with AddResource. That is, I'd like to add a script once to the header even if it's used 200 times in a page.

A custom AddResource implementation could adapt Weblets to manage resources.

Another problem with AddResource is AJAXified components. For instance, with ajax4jsf.

Current implementation of (say) StreamingAddResource uses a very tricky approach to manage stylesheets:

1. You have to use this with t:documentHead which renders a link to pseudo-stylesheet. This links carries an unique id of the requst, for instance:

123/header.css.

2. When rendering the components, they may add some stylesheets to the header. These are gathered in some kind of a map associated with the request id (123).

3. After the rendered html is delivered to the client, the client requests the 123/header.css.

4. This is intercepte by MyFaces which in its turn create a header.css with all 
the
@import url("my-style.css");
for styles that were added by the components.

Scripts are currently managed a bit differently, but I think this is also gonna change.

In my opinion, this is rather a tricky way to shut yourself in the head.

Why not simply pre-render body in a buffer (gathering the styles/scripts for the header or whatever), and then happily render the head with all the gathered resources? A combination of document/head/body components could easily do it. You only need a some tens of kbs buffer to pre-render the body...

So my question before I start implementing something myself is if anyone has done something in this direction, are there alternative AddResource implementations and so on.
Are these issues adressed in JSF 1.2 somehow?

Bye.
/lexi

Reply via email to