Announcement Announcement Module
Collapse
No announcement yet.
AbstractWizardController Validation Back Button Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractWizardController Validation Back Button

    I have implemented a 4 page account creation wizard using the AbstractWizardFormController.

    Form submission and validation appears to work as intended going forward through the wizard.

    I run into problems when I traverse back from say Page 2 to the previous page in this case Page 1 resulting in validation errors from page 2 displayed on Page 1.

    Works as intended:
    Page0 ->(Validate)-> Page1->(Validate)->Page2->(Validate)Finish

    Does not work as intended:
    Page0->Page1->Page2(Leave required fields empty)->Page1 results in Page 2 validation errors being displayed on Page1.

    Is there a parameter or method I need to set/call to clear all validation errors when navigating backwards through AbstractWizardFormController pages?

    My validate() method in the controller uses a case statement to validate each page as the wizard is traversed like so:

    Code:
    validate(command,errors,page,finish){
        AccountValidator accountValidator = (AccountValidator).getValidator();
    switch(page){
    
    case 0:
       accountValidator.validateUserDetails();
    break;
    
    case 1:
       accountValidator.validateAccountDetails();
    break;
    
    case 2:
       accountValidator.validateDepositDetails();
    break;
    }
    }
    thanks in advance.

  • #2
    thus,

    Did you ever find a solution to this problem? I too have run into this problem and wrote the following code to resolve the issue, however, I do not think it's a very elegent solution... At any rate, here's the code:

    Private method in my Wizard controller:

    private boolean isBackButton(HttpServletRequest request){
    for (int i = 0; i < getPages().length; i++) {
    String paramValue = (String)request.getParameter("_target"+i);
    if (paramValue != null && paramValue.trim().equalsIgnoreCase("back")){
    return true;
    }
    }
    return false;
    }

    Override the surpressValidation method as follows:

    protected boolean suppressValidation(HttpServletRequest request) {
    return isBackButton(request);
    }

    This assumes that you've used the word 'Back' for the value of your HTML button, for instance:

    <input type="submit" name="_target0" value="Back">

    If anyone has a more elegent solution, please let us know...

    Thanks!

    Comment

    Working...
    X