6 Replies Latest reply on Sep 23, 2009 7:19 PM by gregcharles.gregcharles.bigfoot.com

    Seam 2.2 Rewrite URL not working

    gregcharles.gregcharles.bigfoot.com

      I'm trying a simple example of URL rewriting, but it's not working for me. I'm using Seam 2.2.0 deployed to JBoss 5.1.0.


      My pages.xml contains:


      <page view-id="/html/index.xhtml">
          <rewrite pattern="/home" />
      </page>
      




      and


      <page view-id="/html/common/linker.xhtml" action="#{linkAction.perform}">
          <rewrite pattern="/link" />
          ...
      





      My components.xml contains:


         
      <web:rewrite-filter view-mapping="*.seam"/>
      





      As far as I can tell from the documentation, that should be all I need. However, none of the internal links appear different, and if enter the URL: http://mysite/home or http://mysite/link?param=something, I just get a 404 page. What am I missing?

        • 1. Re: Seam 2.2 Rewrite URL not working
          mike82
          If you have also file "index.page.xml" or "linker.page.xhtml" in your project you need to put above as well. So fx for index.page.xml:

          <page xmlns="http://jboss.com/products/seam/pages"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
                no-conversation-view-id="/index.xhtml">
                <rewrite pattern="/home" />
          </page>
          • 2. Re: Seam 2.2 Rewrite URL not working
            muhviehstarr

            Greg Charles wrote on Sep 22, 2009 06:12:


            My components.xml contains:

               
            <web:rewrite-filter view-mapping="*.seam"/>
            





            As far as I can tell from the documentation, that should be all I need. However, none of the internal links appear different, and if enter the URL: http://mysite/home or http://mysite/link?param=something, I just get a 404 page. What am I missing?


            I think your rewrite-filter is not correct configured. Because your view-ids ends with .xhtml and you set .seam. See also documentation at 30.1.4.3. URL rewriting

            • 3. Re: Seam 2.2 Rewrite URL not working
              gregcharles.gregcharles.bigfoot.com

              Thanks for the replies!


              @Majkel No, my project uses pages.xml exclusively for configuring the pages. There are no xxx.page.xml files.


              @Frank Really? It's pretty much standard practice to write a page as pagename.xhtml and then access it via pagename.seam, thanks to the Faces Servlet servlet mapping in web.xml. Section 30.1.4.3, which of course I have seen already, says that the view-mapping parameter must match the servlet mapping defined for the Faces Servlet in the web.xml file. Which it does. Just for s and g, I've also tried *.xhtml, *, and /*. All fail equally silently.


              My main frustration comes from the lack of diagnostic information. There are no error messages, or any other indication of where Seam is failing, or even if it's trying at all. How can I get it to give me something to work with?

              • 4. Re: Seam 2.2 Rewrite URL not working
                muhviehstarr

                You're right with configuration issue I posted.


                The only hint I have for you is to look if the RewriteFilter is really initalized and called, and if, so debug the filter.

                • 5. Re: Seam 2.2 Rewrite URL not working
                  mike82
                  Try moving <web:rewrite-filter view-mapping="*.seam"/> up in your components.xml. I placed it just after <core:init .../> Had some problems when it was at end of the document as well.
                  • 6. Re: Seam 2.2 Rewrite URL not working
                    gregcharles.gregcharles.bigfoot.com

                    Thanks guys! Moving the rewrite-filter up helped, but my main problem was one you couldn't possibly have guessed. Our Maven build is doing an overlay, and I didn't realize my component.xml was being overlaid with a different component.xml, which didn't have the rewrite-filter. Now everything is working perfectly ... except that I'm a bit embarrassed. Thanks anyway for all your help.