title: How to embed and call a javascript script in a RichFaces/JSF page
body: <p>I've been looking around for a method to embed and call javascript functions in JSF pages. I'm also using RichFaces.</p>
  
  <p>To define the function, it appears I can do this in a cross-browser supported fashion:</p>
  
  <pre><code>        &lt;a4j:outputPanel ajaxRendered="true"&gt;
          &lt;f:verbatim&gt;
              &lt;script type="text/javascript"&gt;
                  function datum() {
                      alert("hi");
                  }
              &lt;/script&gt;
          &lt;/f:verbatim&gt;
      &lt;/a4j:outputPanel&gt;
  </code></pre>
  
  <p>but I'm not sure how I can call this function when the page loads so the text it returns is embedded in an <code>h:outputPanel</code>.  The plan is to have a js clock embedded in the page which is served to the client.  Note I'm not using the body tag, I'm using facelets <code>ui:composition</code>, <code>f:view</code> (core) and RF RI <code>rich:page</code>.</p>
  
  <p>Thanks</p>