Class ScriptEventHandler

  • All Implemented Interfaces:
    EventHandler

    public final class ScriptEventHandler
    extends java.lang.Object
    implements 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 - a Map containing servlet context, session, request attributes and parameters
    • request - a HttpServletRequest instance
    • response - a HttpServletResponse instance
    • session - a HttpSession instance
    • dispatcher - a LocalDispatcher instance
    • delegator - a Delegator instance
    • security - a Security instance
    • locale - a Locale instance
    • timeZone - a TimeZone instance
    • userLogin - a UserLogin GenericValue

    If the event element includes an invoke attribute, then the matching script function/method will be called with a single argument - the bindings Map.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String module  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void init​(javax.servlet.ServletContext context)
      Initializes the handler.
      java.lang.String invoke​(ConfigXMLReader.Event event, ConfigXMLReader.RequestMap requestMap, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Invoke the web event
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • module

        public static final java.lang.String module
    • Constructor Detail

      • ScriptEventHandler

        public ScriptEventHandler()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletContext context)
                  throws EventHandlerException
        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 interface EventHandler
        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 java.lang.String invoke​(ConfigXMLReader.Event event,
                                       ConfigXMLReader.RequestMap requestMap,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws EventHandlerException
        Description copied from interface: EventHandler
        Invoke the web event
        Specified by:
        invoke in interface EventHandler
        Parameters:
        event - Contains information about what to execute
        requestMap - Contains information about the request-map the event was called from
        request - The servlet request object
        response - The servlet response object
        Returns:
        String Result code
        Throws:
        EventHandlerException