Anonymous avatar Anonymous committed 848bf51

WW-1490 (Upgrade DWR to 2.x version)
- added javadoc
- replace deprecated DWR API usage

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

Comments (0)

Files changed (2)

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

 /**
  * Control who should be accessing which methods on which classes, allowing
  * WebWork to access classes under org.directwebremoting.webwork package.
- * 
+ * <p/>
+ * To configure this, add the following in web.xml
+ * <pre>
+ * &lt;servlet&gt;
+ *       &lt;servlet-name&gt;dwr&lt;/servlet-name&gt;
+ *       &lt;servlet-class&gt;org.directwebremoting.servlet.DwrServlet&lt;/servlet-class&gt;
+ *       &lt;init-param&gt;
+ *           &lt;param-name&gt;debug&lt;/param-name&gt;
+ *           &lt;param-value&gt;true&lt;/param-value&gt;
+ *       &lt;/init-param&gt;
+ *       &lt;init-param&gt;
+ *           &lt;param-name&gt;org.directwebremoting.extend.AccessControl&lt;/param-name&gt;
+ *           &lt;param-value&gt;com.opensymphony.webwork.dwr.WebWorkDwrAccessControl&lt;/param-value&gt;
+ *       &lt;/init-param&gt;
+ *   &lt;/servlet&gt;
+ *
+ *   &lt;servlet-mapping&gt;
+ *       &lt;servlet-name&gt;dwr&lt;/servlet-name&gt;
+ *       &lt;url-pattern&gt;/dwr/*&lt;/url-pattern&gt;
+ *   &lt;/servlet-mapping&gt;
+ * </pre>
+ *
  * @author tmjee
  * @version $Date$ $Id$
  */

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

 /*
- * Copyright (c) 2005 Opensymphony. All Rights Reserved.
+ * Copyright (c) 2007 Opensymphony. All Rights Reserved.
  */
 package com.opensymphony.webwork.validators;
 
 import com.opensymphony.xwork.config.entities.ActionConfig;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import uk.ltd.getahead.dwr.ExecutionContext;
+import org.directwebremoting.WebContext;
+import org.directwebremoting.WebContextFactory;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
 
 /**
- * User: plightbo
- * Date: Dec 11, 2004
- * Time: 6:17:58 PM
+ * Perform validation using DWR. To configure this, add the following to web.xml :-
  * <p/>
- * <dwr>
- * <allow>
- * <create creator="new" javascript="validator" class="com.opensymphony.webwork.validators.DWRValidator"/>
- * <convert converter="bean" match="com.opensymphony.xwork.ValidationAwareSupport"/>
- * </allow>
- * </dwr>
+ * <pre>
+ *  &lt;dwr>
+ *       &lt;allow&gt;
+ *          &lt;create creator="new" javascript="validator" class="com.opensymphony.webwork.validators.DWRValidator"/&gt;
+ *          &lt;convert converter="bean" match="com.opensymphony.xwork.ValidationAwareSupport"/&gt;
+ *      &lt;/allow&gt;
+ *  &lt;/dwr&gt;
+ * </pre>
+ *
+ * @author plightbo
+ * @author tmjee
+ * @version $Date$ $Id$
  */
 public class DWRValidator {
     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();
+        WebContext webContext = WebContextFactory.get();
+        HttpServletRequest req = webContext.getHttpServletRequest();
+        ServletContext servletContext = webContext.getServletContext();
+        HttpServletResponse res = webContext.getHttpServletResponse();
+
+
 
         Map requestParams = new HashMap(req.getParameterMap());
         if (params != null) {
             LOG.error("Error while trying to validate", e);
             return null;
         }
-        finally {
-            System.out.println("********************* end");
-
-        }
     }
 
     public static class ValidatorActionInvocation extends DefaultActionInvocation {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.