Commits

tm_jee  committed 8c28249

WW-1490
Upgrade DWR to 2.x version

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2987573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 261e26d

Comments (0)

Files changed (4)

File src/java/com/opensymphony/webwork/dwr/WebWorkDwrAccessControl.java

+/*
+ * Copyright (c) 2002-2007 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.webwork.dwr;
+
+import org.directwebremoting.extend.Creator;
+import org.directwebremoting.impl.DefaultAccessControl;
+
+import java.lang.reflect.Method;
+
+/**
+ * Control who should be accessing which methods on which classes, allowing
+ * WebWork to access classes under org.directwebremoting.webwork package.
+ * 
+ * @author tmjee
+ * @version $Date$ $Id$
+ */
+public class WebWorkDwrAccessControl extends DefaultAccessControl {
+
+    public static final String WEBWORK_INTEGRATION_PACKAGE = "org.directwebremoting.webwork";
+
+    /**
+     * Check the parameters are not DWR internal but allows it if its webwork integration
+     * {@link #WEBWORK_INTEGRATION_PACKAGE}.
+     * 
+     * @param method The method that we want to execute
+     */
+    protected void assertAreParametersDwrInternal(Method method) {
+        for (int j = 0; j < method.getParameterTypes().length; j++) {
+            Class paramType = method.getParameterTypes()[j];
+            if (paramType.getName().startsWith(WEBWORK_INTEGRATION_PACKAGE)) {
+                // we allow access to WebWork integration stuff.
+                return;
+            }
+            else {
+                super.assertAreParametersDwrInternal(method);
+            }
+        }
+    }
+
+    /**
+     * Is the class that we are executing a method on part of DWR? if so deny but if its
+     * WebWork integration stuff, allows it {@link #WEBWORK_INTEGRATION_PACKAGE}.
+     * 
+     * @param creator The {@link Creator} that exposes the class
+     */
+    protected void assertIsClassDwrInternal(Creator creator) {
+        if (creator.getType().getName().startsWith(WEBWORK_INTEGRATION_PACKAGE)) {
+            // we allow access to WebWork integration stuff.
+            return;
+        }
+        else {
+            super.assertIsClassDwrInternal(creator);
+        }
+    }
+}

File src/java/com/opensymphony/webwork/static/validationClient.js

                 params[e.name] = e.value;
             }
         }
-
-		validator.doPost(function(action) {
-            if (action) {
-                vc.onErrors(input, action);
-            }
-        }, namespace, actionName, params);
+            validator.doPost(namespace, actionName, params, {
+                callback: function(action) {
+                            if (action) {
+                                vc.onErrors(input, action);
+                            }
+                          },
+                timeout: 10000,
+                errorHandler: function(message) {
+                    alert('Error '+message);
+                }
+           });
     }
     
 	return this;

File src/java/com/opensymphony/webwork/validators/DWRValidator.java

     private static final Log LOG = LogFactory.getLog(DWRValidator.class);
 
     public ValidationAwareSupport doPost(String namespace, String action, Map params) throws Exception {
+
+        System.out.println("******************** start");
+
         HttpServletRequest req = ExecutionContext.get().getHttpServletRequest();
         ServletContext servletContext = ExecutionContext.get().getServletContext();
         HttpServletResponse res = ExecutionContext.get().getHttpServletResponse();
             LOG.error("Error while trying to validate", e);
             return null;
         }
+        finally {
+            System.out.println("********************* end");
+
+        }
     }
 
     public static class ValidatorActionInvocation extends DefaultActionInvocation {

File src/java/template/ajax/validation.js

  */
 var webworkValidator = new ValidationClient("$!base/validation");
 webworkValidator.onErrors = function(input, errors) {
-	var form = input.form;
+    var form = input.form;
 
 	clearErrorMessages(form);
 	clearErrorLabels(form);
     element.touched = true;
     var namespace = element.form.attributes['namespace'].nodeValue;
     var actionName = element.form.attributes['name'].nodeValue;
-	webworkValidator.validate(element, namespace, actionName);
+    webworkValidator.validate(element, namespace, actionName);
 }
 
 /*