Hi Mario,

returning back to the AddResource discussion, I have found a nice trick for adding styles.

[description starts here]

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

No, there is no need to render scripts in the head, so for
StreamingAddResource this will not be changed.

Here you point to one nasty HTML problems. In HTML, if you want to add a CSS style file to the HTML page, you have to add a <link> element to the head. With the <style> element, you can only add inline style.

This limitation made you invent this overcomplicated management of styles:

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.


This is very very very tricky as you surely know for yourself. Script management is much simpler.

[end of description]

Ok, and now the little trick that allows you including style files with <style> element. Simply write:

<style type="text/css">@import url("mystyle.css");</style>

That's it! You can manage scripts just like you manage styles - without this awful request tracking and so on.

I've just tried it in my AddResource implementation, works nice, tested in Mozilla, IE and Opera.

Bye.
/lexi

Reply via email to