<t:stylesheet>

The stylesheet provides an easy way to define the stylesheet from a managed bean. The example below will use the stylesheet property of the managed bean applicationSkin to define the stylesheet used by the browser.

<f:view>
  <t:document>
    <t:documentHead>
      <t:stylesheet path="#{applicationSkin.stylesheet}">
    </t:documentHead>
    ....
  <t:document>
</f:view>

Notes about Attributes

Below is additional documentation about attributes. At some point the TagLib Documentation will be updated to include these notes.

path

filtered stylesheet

<f:view>
  <t:document>
    <t:documentHead>
      <t:stylesheet path="/context/path/to/stylesheet.css" filtered="true">
    </t:documentHead>
    ....
  <t:document>
</f:view>

The filtered attribute allows you to direct the tag to filter the real stylesheet and replace every EL string within.

One use case .... hmmm ... the only one I had in mind when doing this enhancement is to keep the context path for background-images dynamic.

Given your stylesheet.css contains the following text

.tableBack
{
        background-image: url(#{environmentInfo.requestContextPath}/images/logo.jpg)
}

and you have configured a managed bean called "environmentInfo" the EL will be replaced by the return value of the beans method. (Notice: A simple .toString() will be issued on the return value as JSF do not allow to use converters without an component).

Notice: My example is not the best in the world as you could simply use a relative path to your image. The path will be searched relative to the stylesheet file.

Still, the filtering might be useful when you e.g. would like to configure colors.

The filtering will happen only on the first access of the stylesheet. Any subsequent access will just deliver a cached result. Means: You can not interweave any request specific stuff in your stylesheet. This make no sense as then you can simply embed the stylesheet into the page.

Style_Sheet (last edited 2009-09-20 23:01:59 by localhost)