Class GenericEventHandler

    • Field Detail

      • layerOfHandleRequest

        protected int layerOfHandleRequest
      • _extraEvents

        protected java.util.List<WebEvent> _extraEvents
      • NO_EVENT_ID

        public static final int NO_EVENT_ID
        This constant represents the ID returned by the getEventID method when there is no event in the request
        Since:
        MicroStrategy Web 9.0.0
        See Also:
        Constant Field Values
      • MULTIPLE_EVENT_SOURCE_SUFFIX

        public static final java.lang.String MULTIPLE_EVENT_SOURCE_SUFFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • GenericEventHandler

        public GenericEventHandler()
        Constructs a GenericEventHandler with empty collection of WebEvent.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of this event handler
        Returns:
        the name of this event handler
      • setName

        public void setName​(java.lang.String name)
        Sets the name to this event handler
        Parameters:
        name - a new name of this event handler
      • getWebEvent

        public WebEvent getWebEvent​(int eventID)
        Returns the specified WebEvent instance which this event handler supports.
        Specified by:
        getWebEvent in interface WebEventHandler
        Parameters:
        eventID - the event id of the WebEvent.
        Returns:
        the specified WebEvent; null if the event is not supported by this event handler.
      • getWebEvent

        protected WebEvent getWebEvent​(int eventID,
                                       RequestKeys keys)
        This method should be used when the eventID passed in is different from the one that is included as a value in the keys parameter
        Parameters:
        eventID -
        keys -
        Returns:
        the specified WebEvent; null if the event is not supported by this event handler.
      • getWebEvent

        protected WebEvent getWebEvent​(RequestKeys keys)
        Decodes the WebEvent from the RequestKeys.
        Parameters:
        keys - request keys
        Returns:
        decoded WebEvent
      • addEventsFromRequestKeys

        public static void addEventsFromRequestKeys​(java.util.ArrayList eventList,
                                                    RequestKeys keys,
                                                    WebComponent component,
                                                    SimpleList filterEventIDList)
      • processRequest

        public boolean processRequest​(RequestKeys keys)
                               throws WebException
        Logic to process the event. Specific event handler implementation extending this class will need to override the default behavior.
        Specified by:
        processRequest in interface WebEventHandler
        Parameters:
        keys - the RequestKeys object containing event ID, sources, and any other information.
        Returns:
        true if handling succeeds; false if the event is ignored and not handled.
        Throws:
        WebException - thrown if handling of the request fails.
      • processMultipleEvents

        public static void processMultipleEvents​(java.lang.String flatState,
                                                 com.microstrategy.web.beans.MultipleEventHandler handler,
                                                 java.lang.String componentPath)
        Processes multiple events encoded via the FlatStateSerializer.
        Parameters:
        flatState - state encoded using the FlatStateSerializer algorithm.
        handler - event handler to pocess request
        Since:
        MicroStrategy Web 8.0.0
      • delegateRequest

        public boolean delegateRequest​(RequestKeys keys)
                                throws WebException
        The default implementation of this method simply delegates the event to the next source component specified in the static field GenericWebEvent.URL_SOURCE_NAME.
        Specified by:
        delegateRequest in interface WebEventHandler
        Parameters:
        keys - the RequestKeys object containing event ID, sources, and any other information.
        Returns:
        true if handling succeeds in processRequest or one of its children.
        Throws:
        WebException - thrown if handling of the request fails.
      • getNextSourceName

        public java.lang.String getNextSourceName​(RequestKeys keys)
        Returns the next component name in the event component path.
        Parameters:
        keys - request keys
        Returns:
        next component name in the event component path.
        Since:
        MicroStrategy Web 8.0.0
      • getNextSourceName

        public static java.lang.String getNextSourceName​(java.lang.String currentBeanPath,
                                                         java.lang.String eventFullPath)
        Returns the next source component which will handle the event. The next source is calculated by finding out the next component following the segement currentBeanPath in the eventFullPath. For example, if
                  String currentBeanPath = "servlet.page";
                  String eventFullPath = "servlet.page.bean1.bean2";
        then this method returns bean1 to the caller.
        Parameters:
        currentBeanPath - the path of the current component which is handling the event.
        eventFullPath - the full path of the event to be handled.
        Returns:
        the name of the next component in the event path; null if there is no next component along the event path.
      • isMyEvent

        protected boolean isMyEvent​(RequestKeys keys)
        Since:
        MicroStrategy Web 9.0.0
      • addEventsFromXML

        public void addEventsFromXML​(java.lang.String eventsXML)
        Deprecated.
        The GenericEventHandler is not responsible to read the xml structure, therefore this method is not used anymore.
        Events should be added to an event handler using the Web Customization Editor
        Adds one or more GenericWebEvent into the current event handler. The root node of event definition XML passed in might be either WebEventTags.TAG_EVENTS or WebEventTags.TAG_EVENT.
        Specified by:
        addEventsFromXML in interface WebEventHandler
        Parameters:
        eventsXML - the XML representation of web events.
        See Also:
        WebEventHandlerFactory
      • addEvents

        public void addEvents​(org.w3c.dom.Element node)
        Deprecated.
        The GenericEventHandler is not responsible to read the xml structure, therefore this method is not used anymore.
        Events should be added to an event handler using the Web Customization Editor
        Adds one or more GenericWebEvent into the current event handler. The root node of event definition XML passed in might be either WebEventTags.TAG_EVENTS or WebEventTags.TAG_EVENT.
        Parameters:
        node - the root node of the XML representation of web events.
        See Also:
        WebEventHandlerFactory
      • addEvent

        protected void addEvent​(org.w3c.dom.Element eventNode)
        Deprecated.
        The GenericEventHandler is not responsible to read the xml structure, therefore this method is not used anymore.
        Events should be added to an event handler using the Web Customization Editor
        Add one GenericWebEvent into the current event handler.
        Parameters:
        eventNode - the root node of a single event.
        See Also:
        WebEventHandlerFactory
      • addEvent

        public void addEvent​(WebEvent event)
        Adds a WebEvent instance into the current event handler.
        Specified by:
        addEvent in interface WebEventHandler
        Parameters:
        event - the WebEvent instance to be added.
      • getHandlerType

        public int getHandlerType()
        Returns the type of the current WebEventHandle.
        Specified by:
        getHandlerType in interface WebEventHandler
        Returns:
        the type of the current event handler.
      • getEventID

        protected static int getEventID​(RequestKeys keys)
        Retrieves the event id passed in from the RequestKeys.
        Parameters:
        keys - the RequestKeys object.
        Returns:
        the ID of the event to be handled; -1 NO_EVENT_ID if the request does not contain any event ID.
      • setHandlerType

        protected void setHandlerType​(int type)
        Sets the type of the current event handler.
        Parameters:
        type - the type of the current event handler.
      • clone

        public java.lang.Object clone()
        Clone the current event handler instance. This is a shallow cloning since the events it holds and the associated WebComponent are not deeply cloned.
        Overrides:
        clone in class java.lang.Object
        Returns:
        the cloned GenericEventHandler.
      • validateRequiredArgument

        protected void validateRequiredArgument​(java.lang.String argName,
                                                java.lang.String argValue)
                                         throws WebException
        A helper method which ensures that the argValue corresponding to argName is not null and not empty.
        Parameters:
        argName - the event argument name.
        argValue - the event argument value to ve validated
        Throws:
        WebException - thrown if argValue is a null string or empty string.
      • getWebEvents

        public java.util.Enumeration getWebEvents()
        Returns an enumeration over the WebEvent suppored by this event handler. The WebEvent are returned in no particular order.
        Specified by:
        getWebEvents in interface WebEventHandler
        Returns:
        an Enumeration over the WebEvent supported.
      • getWebEventsFromRequest

        public java.util.Enumeration getWebEventsFromRequest​(RequestKeys keys)
        Returns an enumeration over the WebEvent suppored by this event handler that are present in the request keys provided. The WebEvent are returned in no particular order.
        Specified by:
        getWebEventsFromRequest in interface WebEventHandler
        Parameters:
        keys - the RequestKeys object.
        Returns:
        an Enumeration over the WebEvent supported.
      • getPendingEvents

        public SimpleList getPendingEvents()
        Returns the list of events that were not processed.
        While handling the request, if after processing an event the page is not in Succesfull state, the EventHandler stops processing the rest of the events. This list resturns those events that remain pending.
        Specified by:
        getPendingEvents in interface WebEventHandler
        Returns:
        a List with the events that were not processed during handleRequest(). If handelRequest() was not invoked, it returns null.
      • isInitialized

        protected boolean isInitialized()
        Returns true after the markInitailized() has been called. It's used to identify if this instance has been initialized with the list of events it supports.
        Since:
        MicroStrategy Web 9.0.0
      • markInitailized

        protected void markInitailized()
        Call this method to mark this event-handler instance as initialized.
        Since:
        MicroStrategy Web 9.0.0
      • appendRemainingEvent

        public void appendRemainingEvent​(WebEvent event)
        Description copied from interface: WebEventHandler
        Append an remaining event at the end of the remaining events' list.
        Such remaining event will be processed at the end.
        Specified by:
        appendRemainingEvent in interface WebEventHandler
        Parameters:
        event - the WebEvent object.