Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
11g Release 1 (11.1.1.7.0)

E12419-09

<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.

Examples:

Include an external CSS file:

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

In-line CSS content:

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

Include an external JS file:

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

In-line JavaScript code:

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

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.