具有验证错误的JSF PRG [英] JSF PRG with validation error
问题描述
我正在将JSF与PRG模式一起使用. (在我的导航规则中使用).
I'm using JSF with the PRG pattern. (use in my navigation rules).
问题是当我收到验证错误(例如:用户未设置必填值)时,重定向未完成(即,帖子后跟随同一页面).
The problem is that the redirect is not done (i.e. a post followed by a get of the same page) when I got validation errors (ex : the mandatory value isn't set by the user).
场景是:
-
用户未输入强制值并提交表单
user doesn't put the mandatory value and submit the form
验证错误,并且显示相同的视图并显示错误 消息(无PRG)
validation error occurs and the same view is shown with an error message (no PRG)
用户设置强制值并提交==>转到下一页 (使用PRG)
the user set the mandatory value and submit ==> GO to the next page (with PRG)
用户单击后退按钮=>问题,因为在 第2步.==>在Firefox中显示文档过期"屏幕
The user click back button => problem because no PRG was done in the step 2. ==> Got a "Document Expired" screen in Firefox
有人可以帮我吗?
谢谢.
史蒂芬(Stéphane)
Stéphane
推荐答案
只需通过ajax提交表单.只需添加
Just submit the form by ajax. It's a matter of adding
<f:ajax execute="@form" render="@form" />
到命令链接和按钮.如果您使用的是<h:message(s)>
,那么我认为它们的格式完全相同,否则您需要将其客户端ID添加到render
.
to the command links and buttons. If you're using <h:message(s)>
, then I assume that they are in the very same form, otherwise you need to add their client IDs to the render
.
通过ajax提交表单时发生的验证错误不会生成历史记录.
Validation errors while submitting the form by ajax won't generate history.
这篇关于具有验证错误的JSF PRG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!