<?xml version="1.0" encoding="UTF-8"?>
<chapter>
  <chapterinfo>
    <keywordset>
      <keyword>a4j:loadScript</keyword>
    </keywordset>
  </chapterinfo>
     <table>
	  <title>Component identification parameters </title>
      <tgroup cols="2">
	  <thead>
            <row>
                  <entry>Name</entry>
                  <entry>Value</entry>
            </row>
        </thead>
        <tbody>
          <row>
            <entry>component-type</entry>
            <entry>org.ajax4jsf.LoadScript</entry>
          </row>
          <row>
            <entry>component-family</entry>
            <entry>org.ajax4jsf.LoadScript</entry>
          </row>
          <row>
            <entry>component-class</entry>
            <entry>org.ajax4jsf.component.html.HtmlLoadScript</entry>
          </row>
          <row>
            <entry>renderer-type</entry>
            <entry>org.ajax4jsf.LoadScriptRenderer</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  
  <section>
        <title>Creating the Component with a Page Tag</title>
    <para>To create the simplest variant on a page use the following syntax:</para>

  <para>
      <emphasis role="bold">Example:</emphasis>
 </para>
    <programlisting role="XML"><![CDATA[<a4j:loadScript src="scripts/someScript.js"/>
]]></programlisting>
  </section>
  <section>
    <title>Creating the Component Dynamically Using Java</title>

  <para>
      <emphasis role="bold">Example:</emphasis>
 </para>
    <programlisting role="JAVA"><![CDATA[import org.ajax4jsf.component.html.HtmlLoadScript;
...
HtmlLoadScript myScript = new HtmlLoadScript();
...
]]></programlisting>
  </section>
  <section>
    <title>Details of usage</title>
    <para>
          The main attribute of the <emphasis role="bold"><property>&lt;a4j:loadScript&gt;</property></emphasis> is <emphasis><property>&quot;src&quot;</property></emphasis>, 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 <code>resource:///</code> prefix to access the script file using RichFaces resource framework.
    </para>
        <para>
              <emphasis role="bold">Example:</emphasis>
        </para>
        <programlisting role="XML"><![CDATA[<a4j:loadScript src="resource:///org/mycompany/assets/script/focus.js" />]]></programlisting>
          <para>
                The <emphasis><property>&quot;src&quot;</property></emphasis> attribute passses value to the <code>getResourceURL()</code> method of the ViewHandler of the application, 
                The result is passed through the <code>encodeResourceURL()</code> method of the ExternalContext. 
          </para>
          
      
</section>

  <section>
    <title>Relevant resources links</title>
	<para>
	      Vizit the <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/script.jsf?c=loadScript">Script page at RichFaces LiveDemo</ulink> for examples of component usage abd their sources.
	</para>
  </section>

</chapter>   