craigmcc 00/11/28 10:35:53
Modified: src/share/org/apache/struts/action ActionServlet.java
Log:
Rearrange the processing in processValidate() as follows:
* If there is a form bean, and the request is not cancelled, call the
form bean's validate() method. Previously, validate() was only called
if the mapping included an "input" property, which could lead to errors
if the developer forgot to include the "input" definition.
* If the validate() method returns one or more errors, and there is no
"input" form to return control to, throw an error 500. The reasoning is
that the application has been mis-configured ("input" attribute missing).
Submitted by: Pierre Metras <genepi@sympatico.ca>
Revision Changes Path
1.37 +15 -12 jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
Index: ActionServlet.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ActionServlet.java 2000/11/26 05:11:30 1.36
+++ ActionServlet.java 2000/11/28 18:35:52 1.37
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
1.36 2000/11/26 05:11:30 craigmcc Exp $
- * $Revision: 1.36 $
- * $Date: 2000/11/26 05:11:30 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
1.37 2000/11/28 18:35:52 craigmcc Exp $
+ * $Revision: 1.37 $
+ * $Date: 2000/11/28 18:35:52 $
*
* ====================================================================
*
@@ -203,7 +203,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.36 $ $Date: 2000/11/26 05:11:30 $
+ * @version $Revision: 1.37 $ $Date: 2000/11/28 18:35:52 $
*/
public class ActionServlet
@@ -1721,14 +1721,6 @@
if (debug >= 1)
log(" Validating input form properties");
- // Has an input form been specified for this mapping?
- String uri = mapping.getInput();
- if (uri == null) {
- if (debug >= 1)
- log(" No input form, no validation");
- return (true);
- }
-
// Was this submit cancelled?
if (request.getParameter(Constants.CANCEL_PROPERTY) != null) {
if (debug >= 1)
@@ -1752,6 +1744,17 @@
}
formInstance.getMultipartRequestHandler().rollback();
+ }
+
+ // Has an input form been specified for this mapping?
+ String uri = mapping.getInput();
+ if (uri == null) {
+ if (debug >= 1)
+ log(" No input form, but validation returned errors");
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ internal.getMessage("noInput",
+ mapping.getPath()));
+ return (false);
}
// Save our error messages and return to the input form if possible
|