The Java EE 7 Tutorial
8.7 Relocatable Resources
You can place a resource tag in one part of a page and specify that it be rendered in another part of the page. To do this, you use the target
attribute of a tag that specifies a resource. Acceptable values for this attribute are as follows.
-
"head"
renders the resource in thehead
element. -
"body"
renders the resource in thebody
element. -
"form"
renders the resource in theform
element.
For example, the following h:outputScript
tag is placed within an h:form
element, but it renders the JavaScript in the head
element:
<h:form> <h:outputScript name="myscript.js" library="mylibrary" target="head"/> </h:form>
The h:outputStylesheet
tag also supports resource relocation, in a similar way.
Relocatable resources are essential for composite components that use stylesheets and can also be useful for composite components that use JavaScript. See The compositecomponentexample Example Application for an example.