Disabling seam's redirect filter

僤鯓⒐⒋嵵緔 提交于 2019-12-05 23:17:42

问题


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.


回答1:


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);



回答2:


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.



来源:https://stackoverflow.com/questions/431652/disabling-seams-redirect-filter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!