svn commit: r671503 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r671503 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java

lektran
Author: lektran
Date: Wed Jun 25 03:43:50 2008
New Revision: 671503

URL: http://svn.apache.org/viewvc?rev=671503&view=rev
Log:
Added some convenience variables for groovy events as suggested by David on the dev list

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java?rev=671503&r1=671502&r2=671503&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/GroovyEventHandler.java Wed Jun 25 03:43:50 2008
@@ -22,8 +22,12 @@
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 
 import org.ofbiz.base.util.GroovyUtil;
+import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.entity.GenericValue;
+
 import javolution.util.FastMap;
 
 public class GroovyEventHandler implements EventHandler {
@@ -38,6 +42,17 @@
             Map<String, Object> groovyContext = FastMap.newInstance();
             groovyContext.put("request", request);
             groovyContext.put("response", response);
+
+            groovyContext.put("dispatcher", request.getAttribute("dispatcher"));
+            groovyContext.put("delegator", request.getAttribute("delegator"));
+            groovyContext.put("security", request.getAttribute("security"));
+            groovyContext.put("locale", UtilHttp.getLocale(request));
+            groovyContext.put("timeZone", UtilHttp.getTimeZone(request));
+            HttpSession session = request.getSession();
+            groovyContext.put("session", session);
+            groovyContext.put("userLogin", session.getAttribute("userLogin"));
+            groovyContext.put("parameters", request.getParameterMap());
+
             Object result = GroovyUtil.runScriptAtLocation(eventPath + eventMethod, groovyContext);
             // check the result
             if (result != null && !(result instanceof String)) {