Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling seam's redirect filter

Tags:

java

seam

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 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"/>

I don't need the redirect-filter and I tried putting something invalid in the url-pattern to "disable" the filter. However that didn't work. So my question is now:

How do I disable the redirect-filter in seam?

I can't find the answer. The seam documentation talks about disabling it in web.xml, but my attempts have not been succesful yet.

like image 639
Matthias van der Vlies Avatar asked Jan 10 '09 20:01

Matthias van der Vlies


2 Answers

I've worked out where the unwanted conversationId query string parameter is coming from.

The <redirect/> results in a call to org.jboss.seam.faces.FacesManager.redirect(String viewId, Map<String, Object> parameters, boolean includeConversationId)

This is called from the following code in org.jboss.seam.faces.Navigator which sets includeConversationId to true:

  FacesManager.instance().redirect(viewId, parameters, true);

I cannot see any way to avoid this, so the fix/workaround is to do the redirect programmatically in the action method with:

  FacesManager.instance().redirect(viewId, parameters, false);
like image 138
Peter Hilton Avatar answered Nov 08 '22 02:11

Peter Hilton


OK, I managed to kill the redirect-filter by adding this to my compononents.xml:

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

However my main problem still exists, so that was apparently not the problem. It still adds the conversationId as an extra query string on the URL. Apperently I'm doing something wrong since it has been done before.

@Adeel Ansari:

components.xml:

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

pages.xml see my initial question.

like image 44
Matthias van der Vlies Avatar answered Nov 08 '22 04:11

Matthias van der Vlies