Package org.apache.ofbiz.webapp.event
Class ScriptEventHandler
java.lang.Object
org.apache.ofbiz.webapp.event.ScriptEventHandler
- All Implemented Interfaces:
EventHandler
Generic Script Event Handler. This event handler uses the javax.script package (JSR-223) to invoke scripts or script functions.
The script event handler will put the following artifacts in the script engine's bindings:
parameters
- aMap
containing servlet context, session, request attributes and parametersrequest
- aHttpServletRequest
instanceresponse
- aHttpServletResponse
instancesession
- aHttpSession
instancedispatcher
- aLocalDispatcher
instancedelegator
- aDelegator
instancesecurity
- aSecurity
instancelocale
- aLocale
instancetimeZone
- aTimeZone
instanceuserLogin
- a UserLoginGenericValue
If the event element includes an invoke attribute, then the matching script function/method will be called
with a single argument - the bindings Map
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
init
(ServletContext context) Initializes the handler.invoke
(ConfigXMLReader.Event event, ConfigXMLReader.RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) Invoke the web event
-
Constructor Details
-
ScriptEventHandler
public ScriptEventHandler()
-
-
Method Details
-
init
Description copied from interface:EventHandler
Initializes the handler. Since handlers use the singleton pattern this method should only be called the first time the handler is used.- Specified by:
init
in interfaceEventHandler
- Parameters:
context
- ServletContext This may be needed by the handler in order to lookup properties or XML definition files for rendering pages or handler options.- Throws:
EventHandlerException
-
invoke
public String invoke(ConfigXMLReader.Event event, ConfigXMLReader.RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException Description copied from interface:EventHandler
Invoke the web event- Specified by:
invoke
in interfaceEventHandler
- Parameters:
event
- Contains information about what to executerequestMap
- Contains information about the request-map the event was called fromrequest
- The servlet request objectresponse
- The servlet response object- Returns:
- String Result code
- Throws:
EventHandlerException
-