11 Replies Latest reply on Dec 12, 2007 4:27 AM by David Corrales

    Can Seam be configured to support JSP and Facelets in an  ap

    Guofeng Zhang Novice

      Hi,

      We are trying to port our web application to Seam.

      We want to use Facelets to newly developed pages and port the existed JSP pages to Facelets in the future.

      I replace javax.faces.DEFAULT_SUFFIX in context-param with facelets.VIEW_MAPPINGS:

       <context-param>
       <param-name>facelets.VIEW_MAPPINGS</param-name>
       <param-value>*.xhtml</param-value>
       </context-param>
      

      but the sample application won't work.

      Could anyone kindly tell me if it is possible or how to do it?

      Thanks for your help very much!

        • 2. Re: Can Seam be configured to support JSP and Facelets in an
          Jim Hazen Expert

          Yes it is. Set your facelets.VIEW_MAPPINGS like you have done and use prefex matching for the JSF servlet.

          <servlet-mapping>
           <servlet-name>Faces Servlet</servlet-name>
           <url-pattern>/faces/*</url-pattern>
          </servlet-mapping>
          


          You can then go to either /faces/somepage.jsp or /faces/somepage.xhtml.

          • 4. Re: Can Seam be configured to support JSP and Facelets in an
            Sergey Vlasov Newbie

            Hello

            I've changed booking example to use jsp, but I'm getting the following error:
            2006-07-10 17:16:21,921 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/seam-booking].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
            java.lang.StackOverflowError
            at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:215)
            at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
            at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:215)
            at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)

            <?xml version="1.0" encoding="UTF-8"?>
            
            <web-app version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
            
             <!-- Seam -->
            
             <listener>
             <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
             </listener>
            
             <!-- Propagate conversations across redirects -->
             <filter>
             <filter-name>Seam Redirect Filter</filter-name>
             <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
             </filter>
            
             <filter-mapping>
             <filter-name>Seam Redirect Filter</filter-name>
             <url-pattern>*.seam</url-pattern>
             </filter-mapping>
            
             <!-- JSF -->
            
             <context-param>
             <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
             <param-value>client</param-value>
             </context-param>
            
             <!--context-param>
             <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
             <param-value>.xhtml</param-value>
             </context-param-->
            
             <context-param>
             <param-name>facelets.VIEW_MAPPINGS</param-name>
             <param-value>*.xhtml</param-value>
             </context-param>
            
             <context-param>
             <param-name>facelets.DEVELOPMENT</param-name>
             <param-value>true</param-value>
             </context-param>
            
             <servlet>
             <servlet-name>Faces Servlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <!-- Faces Servlet Mapping -->
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>*.seam</url-pattern>
             </servlet-mapping>
            
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>/*</url-pattern>
             </servlet-mapping>
            
             <!-- MyFaces -->
             <listener>
             <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
             </listener>
            
             <!-- JSF RI -->
             <!--
             <listener>
             <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
             </listener>
             -->
            
            </web-app>
            
            


            • 5. Re: Can Seam be configured to support JSP and Facelets in an
              Guofeng Zhang Novice

              After changing the servlet mapping according to CptnKirk's instruction, The modified sample works well.

              You please try:

               <filter-mapping>
               <filter-name>Seam Redirect Filter</filter-name>
               <url-pattern>/faces/*</url-pattern>
               </filter-mapping>
              

              and
               <!-- Faces Servlet Mapping -->
               <servlet-mapping>
               <servlet-name>Faces Servlet</servlet-name>
               <url-pattern>/faces/*</url-pattern>
               </servlet-mapping>
              


              I do not know why the program failed when using"/*" as the url-pattern. It can not work here either. It display the same error message as you reported.

              • 6. Re: Can Seam be configured to support JSP and Facelets in an
                Gavin King Master

                 

                "gfzhang" wrote:

                I do not know why the program failed when using"/*" as the url-pattern. It can not work here either. It display the same error message as you reported.


                I don't think JSF supports that....

                • 7. Re: Can Seam be configured to support JSP and Facelets in an
                  Sergey Vlasov Newbie

                  Guofeng

                  I've tried your suggestion but in't work well for me.
                  From http://localhost:8080/seam-booking/ got redirected to http://localhost:8080/seam-booking/home.seam where I got 404 error:

                  HTTP Status 404 - /home.jsp
                  
                  type Status report
                  
                  message /home.jsp
                  
                  description The requested resource (/home.jsp) is not available.
                  Apache Tomcat/5.5.17
                  


                  • 8. Re: Can Seam be configured to support JSP and Facelets in an
                    Guofeng Zhang Novice

                    I modify the booking sample as described above. I did not create any jsp files, so I use the files provided by the sample, that is, use xhtml as the suffix. It works.

                    try

                    http://localhost:8080/seam-booking/faces/home.xhtml


                    or change index.html to
                    <html>
                    <head>
                     <meta http-equiv="Refresh" content="0; URL=faces/home.xhtml">
                    </head>
                    </html>
                    



                    • 9. Re: Can Seam be configured to support JSP and Facelets in an
                      Jim Hazen Expert

                      You'll have an easier time starting a new JSF project from scratch.

                      * Make the above changes and create two files in your web root. test.jsp and test1.xhtml.
                      * Have one use JSP/JSF and the other Facelets/JSF.
                      * Then navigate to /faces/test.jsp and /faces/test.xhtml.

                      Both JSF pages should render.

                      • 10. Re: Can Seam be configured to support JSP and Facelets in an
                        Sergey Vlasov Newbie

                        Guofeng,

                        It's working now. Thank you for your help!

                        • 11. Re: Can Seam be configured to support JSP and Facelets in an
                          David Corrales Newbie

                          Hi everyone,

                          I have a similar problem. I have tried your solutions, but it doesn´t work. My problem is that when I have a datatable in a portlet, and I want to see another page of the datatable, it redirect to faces/home.xhtml, and I don´t want that ir redirect to faces/... because I have my views in webapp directory.

                          Sorry very much, for my english.

                          Mi web.xml is as follows:

                          <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
                           version="2.4">
                          
                           <description>JbossPortalBuscadorOperaciones</description>
                          
                           <context-param>
                           <param-name>javax.portlet.faces.BridgeImplClass</param-name>
                           <param-value>org.apache.myfaces.portlet.faces.bridge.BridgeImpl</param-value>
                           </context-param>
                          
                           <!-- <context-param>
                           <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                           <param-value>org.ajax4jsf.portlet.application.FaceletPortletViewHandler</param-value>
                           </context-param>
                           <filter>
                           <display-name>Ajax4jsf Filter</display-name>
                           <filter-name>ajax4jsf</filter-name>
                           <filter-class>org.ajax4jsf.Filter</filter-class>
                           </filter>
                          
                           <filter-mapping>
                           <filter-name>ajax4jsf</filter-name>
                           <servlet-name>Faces Servlet</servlet-name>
                           <dispatcher>FORWARD</dispatcher>
                           <dispatcher>REQUEST</dispatcher>
                           <dispatcher>INCLUDE</dispatcher>
                           </filter-mapping>-->
                           <!-- Seam -->
                          
                           <listener>
                           <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
                           </listener>
                          
                          
                           <servlet>
                           <servlet-name>Seam Resource Servlet</servlet-name>
                           <servlet-class>org.jboss.seam.servlet.ResourceServlet</servlet-class>
                           </servlet>
                          
                           <servlet-mapping>
                           <servlet-name>Seam Resource Servlet</servlet-name>
                           <url-pattern>/seam/resource/*</url-pattern>
                           </servlet-mapping>
                          
                          
                           <filter>
                           <filter-name>Seam Filter</filter-name>
                           <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                           </filter>
                          
                           <filter-mapping>
                           <filter-name>Seam Filter</filter-name>
                           <url-pattern>/*</url-pattern>
                           </filter-mapping>
                          
                          
                           <!-- JSF -->
                           <!--<context-param>
                           <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                           <param-value>NEKO,TIDY,NONE</param-value>
                           </context-param>-->
                           <!--<context-param>
                           <param-name>org.ajax4jsf.xmlparser.TIDY</param-name>
                           <param-value>/pages/repeater.xhtml,/pages/tabs.xhtml</param-value>
                           </context-param>-->
                          
                           <context-param>
                           <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                           <param-value>server</param-value>
                           </context-param>
                          
                           <context-param>
                           <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                           <param-value>.xhtml</param-value>
                           </context-param>
                          
                           <context-param>
                           <param-name>facelets.DEVELOPMENT</param-name>
                           <param-value>false</param-value>
                           </context-param>
                          
                           <servlet>
                           <servlet-name>Faces Servlet</servlet-name>
                           <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                           <load-on-startup>1</load-on-startup>
                           </servlet>
                          
                           <servlet-mapping>
                           <servlet-name>Faces Servlet</servlet-name>
                           <url-pattern>*.seam</url-pattern>
                           </servlet-mapping>
                          
                           <listener>
                           <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                           </listener>
                          
                           <session-config>
                           <session-timeout>30</session-timeout>
                           </session-config>
                          
                           <welcome-file-list>
                           <welcome-file>index.html</welcome-file>
                           </welcome-file-list>
                          
                          
                          </web-app>
                          


                          If anyone can help me...

                          Thank you anyway.