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.


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


Name Type Supports EL? Description
type String non-deferred One of:
CSS content or URI to a file
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.