Spring Web Flow防止后退按钮使用 [英] Spring Web Flow Preventing Back Button Use

查看:251
本文介绍了Spring Web Flow防止后退按钮使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在项目中使用Spring Web Flow,并希望利用元素上的history =discard和history =invalidate属性。



我把这些属性放在我想要的位置,但是当我尝试通过浏览历史属性在转换后运行时,通过导航到一个视图来测试它们是否工作,它会引导我进入异常页面。


org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException:使用键'e1s1'恢复流程执行时出现问题


当然,这是说我从历史上删除了这个状态,所以找不到它。我真的不明白为什么没有一些内置的机制来处理这个,但除此之外,我还没有找到一种方式来优雅地处理这个异常,以便我可以重定向到错误页面,或者更好地将它们发送回他们来自哪里。

 < view-state id = 第1页 > 
< transition on =gotoNextPageto =page2history =invalidate/>
< / view-state>
< view-state id =page2/>

应该如何实现此行为,以便按第2页上的后退按钮不会创建例外,但只是离开你在第2页?

解决方案

我做了很多搜索。

$ b $ a bref = nofollow>这个旧的论坛帖子有2个解决方案(含示例代码)。



第一个是捕获异常并显示一个使用javascript的页面 forward()返回到原始页面 - 实际上可以撤销后台。



第二个解决方案检查流程状态并将它们发送到最新的有效流程快照。



我很困惑,因为没有出来的解决方案。每个人都必须遇到这个问题。
有兴趣跟进进度的人有 JIRA问题。 / p>

So I'm using Spring Web Flow on a project and want to make use of the history="discard" and history="invalidate" attributes on elements.

I have placed those attributes where I want them, however, when I try to test whether or not they work by navigating to a view after the history attribute is run on the transition, it directs me to an exception page.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key 'e1s1'

So sure, it's saying I deleted that state from the history so it can't find it. I don't really see why there isn't some built in mechanism to handle this in the first place, but that aside, I haven't been able to figure out a way to gracefully handle this exception so that I can just redirect them to an error page or would be nicer to just send them back to where they came from.

<view-state id="page1">
    <transition on="gotoNextPage" to="page2" history="invalidate" />
</view-state>
<view-state id="page2"/>

How is this behavior supposed to be achieved, so that pressing the back button on page2 does not create an exception but just leaves you at page 2?

解决方案

I did a lot of searching on this.

This old forum post has 2 solutions (with sample code).

The first is to catch the exception and display a page that use javascript to forward() back to the original page - in effect undoing the back.

The 2nd solution examines the flow state and sends them to most recent valid flow snapshot.

I'm as perplexed as you are that there is no out of box solution. Everyone must encounter this issue. There is a JIRA issue filed for those interested in following the progress.

这篇关于Spring Web Flow防止后退按钮使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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