5 Replies Latest reply on Jun 6, 2011 11:51 AM by kongo09

    Seam adds unwanted conversationId to URL

    mvdvlies

      I'm doing a project in seam that requires restful URLs. I have a view that is mapped to /group/{group}/{locale}. On that page I have a list of so called messages. Each message has a button to save changes to the message. This is linked to an action bean like this:



      <h:commandButton type="submit" value="Save Changes" action="#{groupAction.update}" />




      Each message has an anchor, so /group/{group}/{locale}#{id} can be used to make the browser go to that anchor. This is why I need a redirect after the POST:


      <page view-id="/group.xhtml">
        <rewrite pattern="/group/{group}/{locale}"/>
          
        <param name="group" value="#{groupAction.group}"/>
        <param name="locale" value="#{groupAction.locale}"/>
            
        <navigation from-action="#{groupAction.update}">
          <redirect view-id="/group.xhtml?group=#{group}&locale=#{locale}##{id}"/>
        </navigation>
      </page>



      Also I have the following redirect rule (UrlRewriteFilter) to get to the proper RESTful URL:


      <outbound-rule>
        <from>^/group.xhtml\?group=([\.\w]+)&locale=([\.\w]+)\#([\.\w]+)\?cid=(\d*)$</from>
        <to type="temporary-redirect" last="true">/group/$1/$2#$3</to>
      </outbound-rule>




      I try to strip the conversationId here. This has been tested an works. However seam still  appends a ?conversationId={cid}. So what's the problem? Well, imagine a URL like /group/{group}/{locale}#{id}?conversationId={cid}. Oviously the browser doesn't like this and will not automatically go to that anchor.


      I did some research and discovered my problem in the seam documentation:



      29.1.4.2. Conversation propagation with redirects





      This filter allows Seam to propagate the conversation context across browser redirects. It intercepts any browser redirects and adds a request parameter that specifies the Seam conversation identifier. The redirect filter will process all requests by default, but this behavior can also be adjusted in components.xml:

      <web:redirect-filter url-pattern="*.seam"/>



      So I disabled the filter using the following snippet in my components.xml:


      <web:redirect-filter disabled="true" installed="false" />



      However I still get the ?conversationID={cid} on the URL.



        • 1. Re: Seam adds unwanted conversationId to URL
          tazman

          I'm trying to achieve the same thing. I have however one additional issue. When I use fragment identifiers in my redirects, I get the '#' encoded as '%23'. So the URL /group/{group}/{locale}#{id} becomes /group/{group}/{locale}%23{id}, which is not correct at all.

          • 2. Re: Seam adds unwanted conversationId to URL
            mvdvlies

            Tom Claire wrote on Jan 12, 2009 11:12:


            I'm trying to achieve the same thing. I have however one additional issue. When I use fragment identifiers in my redirects, I get the '#' encoded as '%23'. So the URL /group/{group}/{locale}#{id} becomes /group/{group}/{locale}%23{id}, which is not correct at all.


            Hi tom,


            There are some options in UrlRewriteFilter to adjust encoding properties on rules. Please refer to the url rewrite manual specifically the encodefirst attribute on the outbound-rule. I hope this helps.

            • 3. Re: Seam adds unwanted conversationId to URL
              geofrank

              I have the same problem, and it ruins my clean URLs. Has somebody filed a JIRA-issue for this? If so, please post a link so I can give my vote.



              <redirect propagation="false"/>


              Sounds like a good idea, and it should also be possible to disable the redirect-filter entirely as stated in the documentation.


              The automatic propagation is a neat feature, but it shouldn't be hard to imagine use-cases where you don't want this behaviour.

              • 4. Re: Seam adds unwanted conversationId to URL
                geofrank

                I filed two JIRA-issues. One bug-report because disabling the web:redirect-filter doesn't work as expected:
                JIRA Issue


                And one feature-request allowing us to disable it on a per-redirect basis: JIRA Issue


                Vote on these if you want the ability to diable conversation propagation when you don't need it.

                • 5. Re: Seam adds unwanted conversationId to URL
                  kongo09

                  I just voted for this request. However, two years down the road, I have not much hope that anyone is listening.