Hi. I have a j2ee web application running on struts. I am using validation XMLs for my form validation. I have a problem with multiple buttons in One form. I have Save, Delete and Cancel buttons. The problem is I want that when the delete button is clicked the validation is not performed. How do I do this.
views:
180answers:
1
A:
Haven't used the Validation framework that much with Struts, but you might do this with overwriting the validate() method in your action form.
The org.apache.struts.validator.ValidatorForm is the Struts entry point into the Validator plugin. The ValidatorForm overrides the validate() method of the ActionForm and delegates validation to the Validator.
You might skip validation for your desired button if you overwrite the validate() method in your form and only call the one in ValidatorForm if needed, something like:
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
if (/* check for clicked button*/) {
//skip validation and just return empty (i.e. no error)
return new ActionErrors();
}
// else, delegate to the validator framework
super.validate(mapping, request);
}
dpb
2010-04-28 13:11:07