Friday, June 26, 2009

Use ERXStyleSheet for CSS Stylesheets

Use Wonder's ERXStyleSheet reusable WOComponent for all your CSS stylesheet needs, even static ones served from your webserver root. This ensures that your changes during development are instantly reflected even for static ones saving you the need to do other fiddling to stop the browser caching your static stylesheets in development.

Example usage for a static stylesheet:

<wo:ERXStyleSheet href = "/lcwr/css/wkgeneric.css" />


For stylesheets in your application's WebServerResources, use it like this:

<wo:ERXStyleSheet filename = "wkgeneric.css" />


For stylesheets in a framework's WebServerResources, use it like this:

<wo:ERXStyleSheet filename = "wkgeneric.css" framework = "MyFramework" />


For dynamic stylesheet generation, you can put styles in the component content and a stylesheet will be dynamically generated, cached and delivered for you. Use this when you want dynamic styles for different users or branding for example. See the javadoc to understand usage of the cache key.

<wo:ERXStyleSheet key = "developmentgrid">

#bd {

background-color: none;

background: url(/lcwr/css/src/grid.png);

}

wo:ERXStyleSheet>



As always, Wonder provides the fast easy way to Get Things Done™


0 comments:

Post a Comment