Results 1 to 2 of 2

Thread: AbstractWizardFormController & Validation

  1. #1

    Default 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. #2
    Join Date
    Jan 2006
    Location
    Beijing
    Posts
    2

    Default

    onBindAndValidate() {

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

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •