You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/08/13 07:58:25 UTC
svn commit: r232422 - in /struts/sandbox/trunk/ti/src/java:
org/apache/ti/interceptor/
org/apache/ti/interceptor/FormValidationInterceptor.java
org/apache/ti/servlet/ServletDispatcherResult.java ti-default.xml
Author: mrdon
Date: Fri Aug 12 22:58:22 2005
New Revision: 232422
URL: http://svn.apache.org/viewcvs?rev=232422&view=rev
Log:
* Adding form validator interceptor to handle action method form parameter
* Removing old servlet dispatcher, not necessary now that we are using webwork
Added:
struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/
struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/FormValidationInterceptor.java
Removed:
struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java
Modified:
struts/sandbox/trunk/ti/src/java/ti-default.xml
Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/FormValidationInterceptor.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/FormValidationInterceptor.java?rev=232422&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/FormValidationInterceptor.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/interceptor/FormValidationInterceptor.java Fri Aug 12 22:58:22 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.interceptor;
+
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.interceptor.AroundInterceptor;
+import com.opensymphony.xwork.validator.*;
+import org.apache.ti.processor.ControllerActionInvocation;
+
+
+
+/**
+ * Validates an action form. This interceptor extends the {@link AroundInterceptor} and implements only the
+ * {@link AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation)} method. This class
+ * simply calls the {@link ActionValidatorManager#validate(java.lang.Object, java.lang.String)} method
+ * with the given Action and its context.
+ *
+ * @author Jason Carreira
+ */
+public class FormValidationInterceptor extends AroundInterceptor {
+
+ /**
+ * Does nothing in this implementation.
+ */
+ protected void after(ActionInvocation dispatcher, String result) throws Exception {
+ }
+
+ /**
+ * Gets the current action form and its context and calls
+ * {@link ActionValidatorManager#validate(java.lang.Object, java.lang.String)}.
+ *
+ * @param invocation the execution state of the Action.
+ * @throws Exception if an error occurs validating the action form.
+ */
+ protected void before(ActionInvocation invocation) throws Exception {
+ ControllerActionInvocation inv = (ControllerActionInvocation)invocation;
+ Object form = inv.getForm();
+ if (form != null) {
+ String context = invocation.getProxy().getActionName();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Validating form from "
+ + invocation.getProxy().getNamespace() + "/" + invocation.getProxy().getActionName() + ".");
+ }
+
+ ActionValidatorManager.validate(form, context);
+ }
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/ti-default.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/ti-default.xml?rev=232422&r1=232421&r2=232422&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/ti-default.xml (original)
+++ struts/sandbox/trunk/ti/src/java/ti-default.xml Fri Aug 12 22:58:22 2005
@@ -33,6 +33,8 @@
<interceptor name="fileUpload" class="com.opensymphony.webwork.interceptor.FileUploadInterceptor"/>
<interceptor name="execAndWait" class="com.opensymphony.webwork.interceptor.ExecuteAndWaitInterceptor"/>
+ <intereceptor name="formValidation" class="org.apache.ti.interceptor.FormValidationInterceptor" />
+
<!-- Basic stack -->
<interceptor-stack name="defaultStack">
<interceptor-ref name="servlet-config"/>
@@ -46,6 +48,7 @@
<interceptor-stack name="validationWorkflowStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="validation"/>
+ <interceptor-ref name="formValidation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org