JSF Relocatable Resources

JSF provides a facility to place your resources at any section of your web page and render it to another section. . You can relocate your resource by specifying target attribute.

You can pass following attributes to relocate in the target attribute.

head: It is used to render the resource in head section.

body: It is used to render the resource in the body section,

form: It is used to render the resource in the form section.

# JSF Relocatable Resources Example

In the following example, we have placed JavaScript file inside the form tag and specified target to head section.

// index.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
<title>Web Resources Example</title>
<h:outputScript  library="js" name="test.js" target="head"/>

Source code of the above web page(index).

You can see that the JavaScript is relocated into the head section.

JSF Relocatable resources 1