title: JSF1.2 to JSF2.1 migration: Using a4j:ajax / f:ajax on First page causes: "ReferenceError: RichFaces / jsf is not defined"
body: <p>I am migrating JSF1.2 application to JSF 2.1. It has a Login page, which uses facelets template. And the template page has h:head tag. Login page has a tag h:selectBooleanCheckbox inside ui:composition/ui:define/h:form/a4j:outputPanel/h:panelGrid/h:panelGroup tags. </p>
  
  <pre><code>&lt;h:selectBooleanCheckbox value="#{bean.alogin}" &gt;
    &lt;a4j:ajax event="click" execute="@form" render="loginPanel" /&gt;    
  &lt;/h:selectBooleanCheckbox&gt;
  </code></pre>
  
  <p>On click of check box, I am getting 'ReferenceError: RichFaces is not defined' in Browser Error Console. </p>
  
  <p>The issue is same even with using f:ajax tag, and having </p>
  
  <pre><code>&lt;h:outputScript name="jsf.js" library="javax.faces" target="head"/&gt;
  </code></pre>
  
  <p>in template page/login page. </p>
  
  <p>This issue (of not finding/loading js libs) is coming only on the First load of Login page. That means if I login to my application and logout and then use the above check box, there is no issue.</p>
  
  <p>Please direct with any pointers and that will be very helpful.
  Thanks very much in advance.</p>
  
  <p>And following is the html generated in head tag:    </p>
  
  <pre><code>&lt;script src="/myapp/javax.faces.resource/jsf.js.faces?ln=javax.faces" type="text/javascript"&gt;&amp;lt;!--
  //--&amp;gt;&lt;/script&gt;
  </code></pre>
  
  <p>I have the two *.faces mappings in web.xml. One is CustomFilter (implementing javax.servlet.Filter) and the other is CustomServlet (extending org.apache.myfaces.webapp.MyFacesServlet).</p>