禁用seam的重定向过滤器 [英] Disabling seam's redirect filter

查看:86
本文介绍了禁用seam的重定向过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在接缝中做一个需要安静网址的项目。我有一个映射到/ group / {group} / {locale}的视图。在那个页面上,我有一个所谓的消息列表。每条消息都有一个按钮,用于保存对消息的更改。这链接到这样的动作bean:

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

每条消息都有一个锚,所以/ group / {group} / {locale}#{id}可用于使浏览器转到该锚点。这就是我在POST后需要重定向的原因:

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>

此外,我还有以下重定向规则(UrlRewriteFilter)来获取正确的RESTful URL:

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>

我在这里删除了conversationId。这已经过测试了。然而,接缝仍会附加'?conversationId = {cid}'。所以有什么问题?好吧,想象一下像'/ group / {group} / {locale}#{id}?conversationId = {cid}'这样的网址。显然浏览器不喜欢这个并且不会自动转到那个锚点。

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。使用重定向进行对话传播
此过滤器允许Seam跨浏览器重定向传播对话上下文。它拦截任何浏览器重定向,并添加一个指定Seam会话标识符的请求参数。默认情况下,重定向过滤器将处理所有请求,但也可以在components.xml中调整此行为:

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

我不需要重定向过滤器,我尝试在url-pattern中放置一些无效的东西禁用过滤器。但是那没用。所以现在我的问题是:

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?

我找不到答案。 seam文档讨论了如何在web.xml中禁用它,但我的尝试还没有成功。

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

推荐答案

我工作过out不需要的 conversationId 查询字符串参数的来源。

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

< redirect /> 会导致对 org.jboss的调用。 seam.faces.FacesManager.redirect(String viewId,Map< String,Object> parameters,
boolean includeConversationId)

这是从 org.jboss.seam.faces.Navigator 中的以下代码调用,它将 includeConversationId 设置为true:

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

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

我看不出任何方法可以避免这种情况,因此修复/解决方法是以编程方式进行重定向action方法:

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

这篇关于禁用seam的重定向过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆