Author: jacopoc
Date: Tue Mar 13 18:23:09 2012
New Revision: 1300268
URL:
http://svn.apache.org/viewvc?rev=1300268&view=revLog:
Now the Script Event Handler properly set the success/error messages returned by the events as request attributes.
Modified:
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ScriptEventHandler.java
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ScriptEventHandler.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ScriptEventHandler.java?rev=1300268&r1=1300267&r2=1300268&view=diff==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ScriptEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ScriptEventHandler.java Tue Mar 13 18:23:09 2012
@@ -105,8 +105,21 @@ public final class ScriptEventHandler im
}
} catch (Exception e) {
Debug.logWarning(e, "Error running event " + event.path + ": ", module);
+ request.setAttribute("_ERROR_MESSAGE_", e.getMessage());
return "error";
}
+ if (result instanceof Map) {
+ Map resultMap = (Map)result;
+ String successMessage = (String)resultMap.get("_event_message_");
+ if (successMessage != null) {
+ request.setAttribute("_EVENT_MESSAGE_", successMessage);
+ }
+ String errorMessage = (String)resultMap.get("_error_message_");
+ if (errorMessage != null) {
+ request.setAttribute("_ERROR_MESSAGE_", errorMessage);
+ }
+ return (String)resultMap.get("_response_code_");
+ }
if (result != null && !(result instanceof String)) {
throw new EventHandlerException("Event did not return a String result, it returned a " + result.getClass().getName());
}