title: Javascript does not work under JSF template
body: <p>I'm using JSF templates and Primefaces. </p>
  
  <p>Javascript code does not seem to be working under ui:composition and ui:define tags. The following code is not hitting the loaded() method. This is the content.xhtml file</p>
  
  <pre><code>&lt;h:head&gt;
  &lt;script language="javascript"&gt;
      function loaded() {
          alert("Working!!");
      }
  &lt;/script&gt;
  &lt;/h:head&gt;
  
  &lt;ui:composition template="/template/template.xhtml"&gt;
  &lt;ui:define name="content"&gt;
  &lt;h:body style="width:100%;height:100%;" onload="loaded()"&gt;
       &lt;p class="item"&gt;Random text&lt;/p&gt;
  &lt;/h:body&gt;
  &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>but when i remove the define and composition tags the loaded function is called. Any idea why this is happening ?</p>
  
  <p>Here is the template file</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"&gt;
  
  
  &lt;h:head&gt;
  &lt;title&gt;&lt;ui:insert name="title"&gt;Template&lt;/ui:insert&gt;&lt;/title&gt;
  &lt;/h:head&gt;
  
  &lt;h:body&gt;
  
  &lt;div id="header"&gt;
      &lt;ui:insert name="header"&gt;
          &lt;ui:include src="../menu.xhtml" /&gt;
      &lt;/ui:insert&gt;
  &lt;/div&gt;
  
  
  &lt;div id="content"&gt;
      &lt;ui:insert name="content"&gt;
          &lt;ui:include src="../content.xhtml" /&gt;
      &lt;/ui:insert&gt;
  &lt;/div&gt;
  
  &lt;div id="footer"&gt;
      &lt;ui:insert name="footer"&gt;
          This is a footer
      &lt;/ui:insert&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
     </p>