Reputation: 1181
I am new to Struts framework, currently I am developing a web based application using struts framework.
As we know that, in Struts application we can override the validate()
in our user-defined Formbean-class to validate the user input, similarly can I override it inside my Action class's execute()?
If I can, after adding the ActionError object to the ActionErrors object, what all I need to do? Just help me with explanation.
Upvotes: 0
Views: 1962
Reputation: 691655
You can't override it, because Action doesn't define any validate()
method. But you can perform validation in an action, yes:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
...
ActionMessages errors = doSomeValidation();
if (!errors.isEmpty()) {
saveErrors(request, errors);
return mapping.getInputForward();
}
...
}
Upvotes: 2