Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.2.3.  < a4j:loadScript > available since 3.0.0

The <a4j:loadScript> component allows to load scripts from alternative sources like a jar files, etc.

Table 6.31. a4j : loadScript attributes

Attribute Name Description
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
id JSF: Every component may have a unique id that is automatically created if omitted
rendered JSF: If "false", this component is not rendered
srcname of JavaScript resource to load.

Table 6.32. Component identification parameters

NameValue
component-typeorg.ajax4jsf.LoadScript
component-familyorg.ajax4jsf.LoadScript
component-classorg.ajax4jsf.component.html.HtmlLoadScript
renderer-typeorg.ajax4jsf.LoadScriptRenderer

To create the simplest variant on a page use the following syntax:

Example:


<a4j:loadScript src="scripts/someScript.js"/>

Example:

import org.ajax4jsf.component.html.HtmlLoadScript;

...
HtmlLoadScript myScript = new HtmlLoadScript();
...

The main attribute of the <a4j:loadScript> is "src" , wich defines the context relative path to the script. The value of the attribute does not require a prefix of an application. Leading slash in the path means the root of the web context. It is also possible to use resource:/// prefix to access the script file using RichFaces resource framework.

Example:


<a4j:loadScript src="resource:///org/mycompany/assets/script/focus.js" />

The "src" attribute passses value to the getResourceURL() method of the ViewHandler of the application, The result is passed through the encodeResourceURL() method of the ExternalContext.

Vizit the Script page at RichFaces LiveDemo for examples of component usage abd their sources.