Differences between revisions 4 and 5
Revision 4 as of 2007-01-24 16:50:21
Size: 2458
Comment:
Revision 5 as of 2009-09-20 23:01:59
Size: 2460
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 16: Line 16:
Below is additional documentation about attributes. At some point the [http://myfaces.apache.org/tomahawk/tlddoc/index.html TagLib Documentation] will be updated to include these notes. Below is additional documentation about attributes. At some point the [[http://myfaces.apache.org/tomahawk/tlddoc/index.html|TagLib Documentation]] will be updated to include these notes.

<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

  • EL can be used, as in the example above. By getting the stylesheet from a managed bean, it can be set, and changed, at runtime to allow the user interface to dynamically be skinned.

  • Stylesheet must start with a slash, i.e. /stylesheet.css or be a fully qualified url, i.e. http://foo.com/stylesheet.css

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)