title: JSF Javascript failure - myfaces not defined
body: <p>I'm working on a web solution using myfaces and primefaces. We have several pages in our solution, and some of the get this mystical error <code>myfaces not defined</code> because there is a javascript file that is not included on the page, namely the <code>jsf.js</code> file:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/driwkraft-hig/javax.faces.resource/jsf.js.xhtml?ln=javax.faces&amp;stage=Development"&gt;
  </code></pre>
  
  <p>The error occurs when clicking on certain commandlinks on the page, where the generated javascript has been set to <code>onClick="myfaces.oam.submitForm...</code></p>
  
  <p>Now, I understand that this is something that the JSF framework adds to the page based on some mystical criteria which I fail to understand. There are pages that appear to be equal with regards to what elements are used, and it succeeds on one and fails on the other. </p>
  
  <p>I have tried to create a test-file where I copied content of one of the failing pages and then removed parts until it would work to figure out what was the source of the problem, but this did not give me anything. My next hunch is that it might be some configuration-error somewhere. But I am completely and utterly blank as to where to start. </p>
  
  <p>I understand I should probable add some code or xml in to this question, but I cannot post the entire solution so I think it is best to do so upon request. Would the web.xml be useful? How about the faces-config.xml? </p>
  
  <p>Any guidance and thoughts are much appreciated!</p>
  
  <hr>
  
  <p>Edit - adding template</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
      &lt;ui:insert name="metadata" /&gt;
      &lt;h:head&gt;
          ....
          &lt;title&gt;
              &lt;ui:insert name="title"&gt;
                  ....
              &lt;/ui:insert&gt;
          &lt;/title&gt;
  
      &lt;/h:head&gt;
      &lt;h:body&gt;
          ....
          &lt;ui:insert name="content"&gt;
              ....
          &lt;/ui:insert&gt;
          ...
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>Edit - adding template client</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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:dp="http://java.sun.com/jsf/composite/dapsys"&gt;
      &lt;ui:composition template="/templates/default.xhtml"&gt;
          &lt;ui:define name="title"&gt;TITLE&lt;/ui:define&gt;
          &lt;ui:define name="metadata"&gt;
              &lt;f:metadata&gt;
                  &lt;f:viewParam name="customerId" value="#{CustomerController.customerId}"&gt;
                  &lt;/f:viewParam&gt;
                  &lt;f:viewParam name="edit" value="#{CustomerController.edit}"&gt;
                  &lt;/f:viewParam&gt;
                  &lt;f:viewParam name="activeTab" value="#{CustomerController.activeTab}"&gt;
                  &lt;/f:viewParam&gt;
              &lt;/f:metadata&gt;
          &lt;/ui:define&gt;
          &lt;ui:define name="content"&gt;
              ...
          &lt;/ui:define&gt;
      &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>