Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
11g Release 2 (11.1.2.0.0)

E17491-02

<af:resource>


resource resource

JSP tag that defines a CSS or JavaScript resource to be included in the HTML head element of the page.

The resource is added to the af:document component to be included when the document is rendered. The resource is only processed on the initial creation of the document. Only JSP tags may be used in the body, no JSF components are supported, or deferred EL expressions as the value is processed during tag execution, not during component tree rendering. If the source attribute is not given, the content of the tag is used for in-line CSS style or JavaScript, otherwise the source attribute is used as the URI to the resource.

af:resource must be a descendent of af:document.

af:resource is not compatible with the Trinidad application view cache. Meaning that org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE must be set to false. A work-around to this limitation is to use the trh:script tag instead for JavaScript resources.

Include an external CSS file:

<source><af:resource type="css" source="/customStyles.css"/></source>

In-line CSS content:

<source><af:resource type="css"> DIV.customStyle { color: red; } </af:resource></source>

Include an external JS file:

<source><af:resource type="javascript" source="/customCode.js"/></source>

In-line JavaScript code:

<source><af:resource type="javascript"> function clientListenerFunction(event) { // content ... } </af:resource></source>

Attributes

Name Type Supports EL? Description
type String non-deferred One of:
css
CSS content or URI to a file
javascript
JavaScript code or URI to a file
source String non-deferred The URI of the source of the external resource to include in the page. If the URI starts with a slash ('/'), the URI will be made context relative, if it starts with two slashes ('//'), it will be made server relative. All others are non-absolute URIs are relative to URI location in the browser. If not given, the resource content will be taken from the tag body.