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

  • AbstractWizardFormController & Validation

    Does anyone know of an easy way to disable validation in the event a user clicks the Back button while stepping through a form wizard?

    I've come up with a potential solution, however, I don't think it's the most elegent of solutions. I was kind of hoping the Spring framework would automatically disable validation (or give you the option to automatically disable validation) in the event a user attempts to move backward in a wizard.

    Anyhow, here's what I've come up with so far:

    Override the suppressValidation method as follows:

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

    Create the following isBackButton private method:

    private boolean isBackButton(HttpServletRequest request){
    try {
    for (int i = 0; i < getPages().length; i++) {
    String paramValue = RequestUtils.getStringParameter(request, "_target"+i);
    if (paramValue != null && paramValue.trim().equalsIgnoreCase("back")){
    System.out.println("Back button was pushed!!");
    return true;
    }
    }

    } catch (ServletRequestBindingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return false;
    }

    Thanks!

  • #2
    onBindAndValidate() {

    if(page == 2 && WebUtils.hasSubmitParameter(request, "forward")) {
    // some validate code
    }

    }

    Comment

    Working...
    X