JSF PRG with validation error

核能气质少年 提交于 2019-12-04 03:38:29

问题


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

The scenario is :

  1. user doesn't put the mandatory value and submit the form

  2. validation error occurs and the same view is shown with an error message (no PRG)

  3. the user set the mandatory value and submit ==> GO to the next page (with PRG)

  4. The user click back button => problem because no PRG was done in the step 2. ==> Got a "Document Expired" screen in Firefox

Can anyone help me please?

Thanks in advance.

Stéphane


回答1:


Just submit the form by ajax. It's a matter of adding

<f:ajax execute="@form" render="@form" />

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.

Validation errors while submitting the form by ajax won't generate history.



来源:https://stackoverflow.com/questions/14727606/jsf-prg-with-validation-error

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