Stéphane
Stéphane

Reputation: 524

JSF PRG with validation error

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

Upvotes: 4

Views: 585

Answers (1)

BalusC
BalusC

Reputation: 1108632

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.

Upvotes: 2

Related Questions