You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Kevin Duffey <kd...@buymedia.com> on 2000/06/21 07:24:08 UTC
Struts - latest build - possible change
Hi,
Craig,
In the ActionServlet class, I recommend a "minor" change...
protected boolean processValidate(ActionMapping mapping,
ActionForm formInstance, HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Skip validation if it is not appropriate
if (formInstance == null)
return (true);
if (!(formInstance instanceof ValidatingActionForm))
return (true);
if (mapping.getInputForm() == null)
return (true);
// Perform the requested validation
if (debug >= 1)
log(" Validating bean properties");
String errors[] = ((ValidatingActionForm) formInstance).validate();
if ((errors == null) || (errors.length == 0))
return (true);
// Save our error messages and return to the input form
String uri = mapping.getInputForm();
if (debug >= 1)
log(" Form validation error: redirecting to: " + uri);
request.setAttribute(Action.ERROR_KEY, errors);
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
rd.forward(request, response);
return (false);
}
in this method, possibly add the ability to response.sendRedirect() to the
page, like you do in the process() call for ActionForward (true/false for
forward/redirect).
Yeah/Nay?