Announcement Announcement Module
No announcement yet.
do not validate when going backwards, my solution Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • do not validate when going backwards, my solution

    I have a 2 pages wizard built upon AbstractWizardFormController. Wizard is primarily one way. i.e. the 'finish' is on the last page.

    On the second page, I have a 'dirty' 'back' button (using a _target0 field).

    if user fills up page 0, then goes to next, then uses Back without filling the form correctly, the validatePage() method is called as per the AbstractWizard... specification. And the 'errors' parameter is filled up with errors from the page 1 validation. But the user is going to see page 0 again. Hence using something like:

    <c:forEach var="error" items="${status.errorMessages}">
    <c:out value="${error}"/>

    would be disturbing.

    My current solution involves caching the targetPage inside the wizard instance (I retrieve it using this.getTargetPage(...) from the onBindAndValidate()) and reuse it inside the validatePage() to avoid computing errors when the getTargetPage is lower than the page argument (i.e. I am going backwards). I could also revalidate the previous page instead, but there should be no need in my case.

    Does that sound like a good trick?

  • #2
    What do you mean by caching?