-
Nov 6th, 2005, 02:45 PM
#1
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!
-
Jan 5th, 2006, 11:28 PM
#2
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
-
Forum Rules