This is an automated email from the ASF dual-hosted git repository.

vlamp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit d9a9eb330c515a68f645baae30b6ea7cf94cb2f2
Author: Volker Lamp <vl...@apache.org>
AuthorDate: Wed Apr 5 20:48:08 2023 +0200

    TAP5-1733: Added FormsRequirePostException
---
 .../commons/util/FormsRequirePostException.java    | 38 ++++++++++++++++++++++
 .../apache/tapestry5/corelib/components/Form.java  |  3 +-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git 
a/commons/src/main/java/org/apache/tapestry5/commons/util/FormsRequirePostException.java
 
b/commons/src/main/java/org/apache/tapestry5/commons/util/FormsRequirePostException.java
new file mode 100644
index 000000000..892eb226c
--- /dev/null
+++ 
b/commons/src/main/java/org/apache/tapestry5/commons/util/FormsRequirePostException.java
@@ -0,0 +1,38 @@
+// Copyright 2023 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.commons.util;
+
+import org.apache.tapestry5.commons.internal.util.TapestryException;
+
+/**
+ * Exception thrown by Tapestry's {@link 
org.apache.tapestry5.corelib.components.Form} component
+ * when the request method is other than POST.
+ * 
+ * @see org.apache.tapestry5.corelib.components.Form
+ * @see org.apache.tapestry5.services.RequestExceptionHandler
+ * 
+ * @since 5.8.3
+ */
+public class FormsRequirePostException extends TapestryException {
+
+    private static final long serialVersionUID = 1L;
+
+    public FormsRequirePostException(String message, Throwable cause) 
+    {
+        super(message, cause);
+    }
+
+       
+}
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
index f0cc2680d..90f20ede7 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
@@ -20,6 +20,7 @@ import org.apache.tapestry5.commons.Messages;
 import org.apache.tapestry5.commons.internal.util.TapestryException;
 import org.apache.tapestry5.commons.services.PropertyAccess;
 import org.apache.tapestry5.commons.util.ExceptionUtils;
+import org.apache.tapestry5.commons.util.FormsRequirePostException;
 import org.apache.tapestry5.corelib.ClientValidation;
 import org.apache.tapestry5.corelib.internal.ComponentActionSink;
 import org.apache.tapestry5.corelib.internal.FormSupportImpl;
@@ -719,7 +720,7 @@ public class Form implements ClientElement, 
FormValidationControl
         String[] values = request.getParameters(FORM_DATA);
 
         if (!request.getMethod().equals("POST") || values == null)
-            throw new 
RuntimeException(messages.format("core-invalid-form-request", FORM_DATA));
+            throw new 
FormsRequirePostException(messages.format("core-invalid-form-request", 
FORM_DATA), null);
 
         // Due to Ajax there may be multiple values here, so
         // handle each one individually.

Reply via email to