JBoss.org Community Documentation

- Prev
- Next

## 6.12. < a4j:loadStyle >

### 6.12.1. Description

The component Inserts stylesheet links to the head element. Render the value of the component, after passing it to the `getResourceURL()` method of the ViewHandler for this application, and passing the result through the `encodeResourceURL()` method of the ExternalContext.

Table 6.23. a4j : loadStyle attributes

Attribute Name | Description
--- | ---
binding | The attribute takes a value-binding expression for a component property of a backing bean
id | Every component may have a unique id that is automatically created if omitted
media | This attribute defines the device to which it is necessary to apply style registration. The possible values are "all", "screen" (by default), "print", "projection", "projection", "braille" and "speech".
rendered | If "false", this component is not rendered
src | name of JavaScript resource to load.

Table 6.24. Component identification parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.LoadStyle
component-family | org.ajax4jsf.LoadStyle
component-class | org.ajax4jsf.component.html.HtmlLoadStyle
renderer-type | org.ajax4jsf.LoadStyleRenderer

### 6.12.2. Creating on a page

To create the simplest variant on a page use the following syntax:

Example:

    <a4j:loadStyle src="styles/style.css"/>

### 6.12.3. Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.HtmlLoadStyle;

    ...

    HtmlLoadScript myStyle = new HtmlLoadStyle();

    ...

### 6.12.4. Key attributes and ways of usage

As it was mentioned above this component returns its value as the value of the "src" attribute passing it to the `getResourceURL()` method of the ViewHandler for this application, and passing the result via the `encodeResourceURL()` method of the ExternalContext.

It means that the Context is inserted automatically to the link. And calls like `resource://` is properly handled.

Except this - you may be free to put your stylesheet links right from the child page while using facelets templates.

### 6.12.5. Relevant resources links

Some additional information about usage of component can be found here.

- Prev6.11. < a4j:loadScript >
- Top of page
- Front page
- Next6.13. < a4j:log >