[英]Navigation on validation failure in Seam/JSF
I've been playing with Seam (2.0.2.SP1) for a few weeks, and I have most of the basics nailed down, but I haven't come up with a decent solution to the following. 我玩Seam (2.0.2.SP1)已经有几个星期了,我已经掌握了大部分基础知识,但是我还没有针对以下方面提出一个不错的解决方案。
Suppose I have a form at /foo.xhtml
, with a rewrite rule such that URLs like /foo.seam?id=<fooId>
are converted to /foo/<fooId>
. 假设我在/foo.xhtml
处有一个带有重写规则的表单,使得诸如/foo.seam?id=<fooId>
类的URL转换为/foo/<fooId>
。 There's a commandButton
on the form with an action of #{fooHome.update}
. 有一个commandButton
与诉讼的形式#{fooHome.update}
。 I also have a navigation rule in /foo.page.xml
that redirects back to a nice, bookmark-friendly GET after a successful POST: 我在/foo.page.xml
中也有一个导航规则,该规则可以在成功执行POST之后重定向回一个不错的,书签友好的GET:
<navigation from-action="#{fooHome.update}">
<rule if-outcome="updated">
<redirect view-id="/foo.xhtml">
<param name="id" value="#{fooHome.instance.id}"/>
</redirect>
</rule>
</navigation>
The problem is when a validation error occurs, at which point the navigation rules get skipped, and I end up at /foo
after the POST. 问题是当发生验证错误时,导航规则将被跳过,并且我在POST之后以/foo
结尾。
My question: Is there a way to redirect on validation errors, so I end up with a GET request for /foo/<fooId>
instead of the POST to /foo
? 我的问题:有没有一种方法可以重定向验证错误,所以我最终获得了对/foo/<fooId>
的GET请求,而不是对/foo
的POST?
I tried rolling my own validation methods in fooHome
, returning a "failed" outcome, but I don't really want invalid data getting past the validation phase (and thus into the current conversation). 我尝试在fooHome
滚动我自己的验证方法,返回“失败”结果,但是我真的不希望无效数据通过验证阶段(因此进入当前对话)。
You would normally redisplay the same view on a validation failure, rather than redirect. 您通常会在验证失败时重新显示相同的视图,而不是重定向。 Assuming that you are using UrlRewrite for the rewrite rules, perhaps you can use an outbound-rule so that the /foo/{fooId} URL is still shown in this case. 假设您将UrlRewrite用于重写规则,则也许可以使用出站规则,以便在这种情况下仍显示/ foo / {fooId} URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.