8 Replies Latest reply on Nov 26, 2009 3:19 AM by benterich

    Script and Style includes not generated

      Hi there,

      we got a problem with our JSF 1.2 application using Richfaces 3.3.3. Our current setup involves:

      - JSF 1.2 (Apache MyFaces 1.2.7)
      - Facelets 1.1.14
      - RichFaces 3.3.3
      - running on Glassfish.

      All the standard JSF stuff runs fine, even RichFaces works fine, to the point where it doesn't generate the needed script and style includes in the section of the rendered html, resulting in JavaScript errors, as e.g. A4J.AJAX is not defined. The links to the underlying JavaScript libraries are just not there in the resulting output.

      After debugging through the responsible parts and turning on tracing for org.ajax4jsf, it looks like the URIs are generated, but the and elements just never make it to the of the output html.

      Any pointers where to look would be very much appreciated.

      Regards,
      Christian

        • 1. Re: Script and Style includes not generated

           

          "benterich" wrote:
          Hi there,

          we got a problem with our JSF 1.2 application using Richfaces 3.3.3. Our current setup involves:

          - JSF 1.2 (Apache MyFaces 1.2.7)
          - Facelets 1.1.14
          - RichFaces 3.3.3
          - running on Glassfish.

          All the standard JSF stuff runs fine, even RichFaces works fine, to the point where it doesn't generate the needed script and style includes in the head-section of the rendered html, resulting in JavaScript errors, as e.g. A4J.AJAX is not defined. The links to the underlying JavaScript libraries are just not there in the resulting output.

          After debugging through the responsible parts and turning on tracing for org.ajax4jsf, it looks like the URIs are generated, but the link and script
          elements just never make it to the head of the output html.

          Any pointers where to look would be very much appreciated.

          Regards,
          Christian


          this is the correct post.

          • 2. Re: Script and Style includes not generated
            nbelaevski

            Hi Christian,

            Please post web.xml contents.

            • 3. Re: Script and Style includes not generated
              juangon

               

              "benterich" wrote:
              "benterich" wrote:
              Hi there,

              we got a problem with our JSF 1.2 application using Richfaces 3.3.3. Our current setup involves:

              - JSF 1.2 (Apache MyFaces 1.2.7)
              - Facelets 1.1.14
              - RichFaces 3.3.3
              - running on Glassfish.

              All the standard JSF stuff runs fine, even RichFaces works fine, to the point where it doesn't generate the needed script and style includes in the head-section of the rendered html, resulting in JavaScript errors, as e.g. A4J.AJAX is not defined. The links to the underlying JavaScript libraries are just not there in the resulting output.

              After debugging through the responsible parts and turning on tracing for org.ajax4jsf, it looks like the URIs are generated, but the link and script
              elements just never make it to the head of the output html.

              Any pointers where to look would be very much appreciated.

              Regards,
              Christian


              this is the correct post.


              You don't have to use Apache MyFaces inside glassfish server if you don't want to. It has Sun JSF RI as bundled server libraries...

              • 4. Re: Script and Style includes not generated

                Ok we got halfway to the solution of our problem. The problem seemed to be that I had the content type of the facelet set to "application/xml" (due to a XSLT processing that happens as final step on the webserver). This content type resulted in the head elements not being rendered, as RichFaces does not find a parser for content type "application/xml".

                The only hint in this direction was an innocent log line "Parser not have support for the such content type, send response as-is" (org.ajax4jsf.webapp.BaseXMLFilter).

                Unfortunately the web server (and the XSLT transformation via mod_xt) REQUIRE content type "application/xml".

                Is there a way to configure an additional parser in RichFaces for XML?

                Thank for your replies, regards.
                Christian

                • 5. Re: Script and Style includes not generated

                   

                  "nbelaevski" wrote:
                  Hi Christian,

                  Please post web.xml contents.


                  web.xml (the relevant parts anyway):
                   <context-param>
                   <param-name>org.richfaces.SKIN</param-name>
                   <param-value>classic</param-value>
                   </context-param>
                  
                   <!-- Facelets suffix -->
                   <context-param>
                   <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                   <param-value>.xhtml</param-value>
                   </context-param>
                  
                   <!-- Resource Resolver (involves Classpath) -->
                   <context-param>
                   <param-name>facelets.RESOURCE_RESOLVER</param-name>
                   <param-value>my.ClasspathResolver</param-value>
                   </context-param>
                  
                   <!-- Facelet View Handler -->
                   <context-param>
                   <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                   <param-value>my.ViewHandler</param-value>
                   </context-param>
                  
                   <!-- Do not render comments in Facelets -->
                   <context-param>
                   <param-name>facelets.SKIP_COMMENTS</param-name>
                   <param-value>true</param-value>
                   </context-param>
                  
                   <listener>
                   <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
                   </listener>
                  
                   <listener>
                   <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                   </listener>
                  
                   <!-- JSF: AJAX 4 JSF -->
                   <filter>
                   <filter-name>ajax4jsfFilter</filter-name>
                   <display-name>Ajax4jsf Filter</display-name>
                   <description>Adds ajax functionality to the application</description>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
                   </filter>
                  
                   <!-- JSF: AJAX 4 JSF -->
                   <filter-mapping>
                   <filter-name>ajax4jsfFilter</filter-name>
                   <servlet-name>Faces Servlet</servlet-name>
                   <dispatcher>REQUEST</dispatcher>
                   <dispatcher>FORWARD</dispatcher>
                   <dispatcher>INCLUDE</dispatcher>
                   </filter-mapping>
                  
                   <!-- filter-mapping>
                   <filter-name>ajax4jsfFilter</filter-name>
                   <url-pattern>*.jsf</url-pattern>
                   </filter-mapping -->
                  
                   <!-- JSF: Faces Servlet Mapping -->
                   <servlet-mapping>
                   <servlet-name>Faces Servlet</servlet-name>
                   <url-pattern>*.jsf</url-pattern>
                   </servlet-mapping>
                  


                  (I hope I got it all)

                  • 6. Re: Script and Style includes not generated

                     

                    "juangon" wrote:

                    You don't have to use Apache MyFaces inside glassfish server if you don't want to. It has Sun JSF RI as bundled server libraries...


                    I know, we just chose MyFaces for different reasons. Supposedly Glassfish has no problems with that setup.

                    • 7. Re: Script and Style includes not generated
                      nbelaevski

                      Hi Christian,

                      Yes, application/xml should be passed through filter unchanged, so it behaves correctly there. Try setting forceparser=true.

                      • 8. Re: Script and Style includes not generated

                        Thank you so much, after setting

                        <filter>
                         <filter-name>ajax4jsfFilter</filter-name>
                         <display-name>Ajax4jsf Filter</display-name>
                         <description>Adds ajax functionality to the application</description>
                         <filter-class>org.ajax4jsf.Filter</filter-class>
                         <init-param>
                         <param-name>forceparser</param-name>
                         <param-value>true</param-value>
                         </init-param>
                        </filter>
                        


                        like you suggested it works, with content type set to "application/xhtml+xml".

                        To wrap it up:

                        1. Symptom
                        - Head elements (scripts and styles) for RichFaces/Ajax4JSF are not included in generated output (while content type set to "application/xml")

                        2. Problem:
                        - Configured filter passes XML through unchanged
                        - therefore head elements are not rendered

                        3. Solution
                        - Setting content type of facelets to "application/xhtml+xml"
                        - Adding "forceparser=true" to Ajax4JSF-Filter


                        Thanks for your help - very much appreciated.