public class

GenericEventHandler

extends Object
implements WebEventHandler WebEventTags Cloneable
java.lang.Object
   ↳ com.microstrategy.web.beans.GenericEventHandler
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This class provides the default implementation of the interface WebEventHandler.

The clone method provides a shallow cloning of the contained collection of WebEvent, as well as the associated WebComponent.

Summary

Nested Classes
class GenericEventHandler.GenericEventKeys This inner class is an implementation of the request keys specific for an event. 
Constants
String MULTIPLE_EVENT_SOURCE_SUFFIX
int NO_EVENT_ID This constant represents the ID returned by the getEventID method when there is no event in the request
[Expand]
Inherited Constants
From interface com.microstrategy.web.beans.WebEventTags
Fields
protected List<WebEvent> _extraEvents
protected int layerOfHandleRequest
Public Constructors
GenericEventHandler()
Constructs a GenericEventHandler with empty collection of WebEvent.
Public Methods
void addEvent(WebEvent event)
Adds a WebEvent instance into the current event handler.
void addEvents(Element node)
This method is 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
void addEventsFromXML(String eventsXML)
This method is 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
void appendRemainingEvent(WebEvent event)
Append an remaining event at the end of the remaining events' list.
Object clone()
Clone the current event handler instance.
boolean delegateRequest(RequestKeys keys)
The default implementation of this method simply delegates the event to the next source component specified in the static field GenericWebEvent.URL_SOURCE_NAME.
int getHandlerType()
Returns the type of the current WebEventHandle.
String getName()
Returns the name of this event handler
String getNextSourceName(RequestKeys keys)
Returns the next component name in the event component path.
static String getNextSourceName(String currentBeanPath, String eventFullPath)
Returns the next source component which will handle the event.
SimpleList getPendingEvents()
Returns the list of events that were not processed.
Class getSupportedWebComponentType()
Returns the WebComponent class by default.
WebComponent getWebComponent()
Returns the WebComponent object associated with the current event handler.
WebEvent getWebEvent(int eventID)
Returns the specified WebEvent instance which this event handler supports.
Enumeration getWebEvents()
Returns an enumeration over the WebEvent suppored by this event handler.
Enumeration getWebEventsFromRequest(RequestKeys keys)
Returns an enumeration over the WebEvent suppored by this event handler that are present in the request keys provided.
boolean handleRequest(RequestKeys keys)
Handles the WebEvent specified in the RequestKeys object.
void processExtraEvents()
static void processMultipleEvents(String flatState, MultipleEventHandler handler)
static void processMultipleEvents(String flatState, MultipleEventHandler handler, String componentPath)
Processes multiple events encoded via the FlatStateSerializer.
boolean processRequest(RequestKeys keys)
Logic to process the event.
void setName(String name)
Sets the name to this event handler
void setWebComponent(WebComponent component)
Sets a WebComponent instance on this event handler.
Protected Methods
void addEvent(Element eventNode)
This method is 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
static int getEventID(RequestKeys keys)
Retrieves the event id passed in from the RequestKeys.
WebComponent getEventTarget(RequestKeys keys)
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
WebEvent getWebEvent(RequestKeys keys)
Decodes the WebEvent from the RequestKeys.
boolean isInitialized()
Returns true after the markInitailized() has been called.
boolean isMyEvent(RequestKeys keys)
void markInitailized()
Call this method to mark this event-handler instance as initialized.
void setHandlerType(int type)
Sets the type of the current event handler.
void validateRequiredArgument(String argName, String argValue)
A helper method which ensures that the argValue corresponding to argName is not null and not empty.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.microstrategy.web.beans.WebEventHandler

Constants

public static final String MULTIPLE_EVENT_SOURCE_SUFFIX

Constant Value: "_me"

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

Constant Value: -1 (0xffffffff)

Fields

protected List<WebEvent> _extraEvents

protected int layerOfHandleRequest

Public Constructors

public GenericEventHandler ()

Constructs a GenericEventHandler with empty collection of WebEvent.

Public Methods

public void addEvent (WebEvent event)

Adds a WebEvent instance into the current event handler.

Parameters
event the WebEvent instance to be added.

public void addEvents (Element node)

This method is 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 TAG_EVENTS or TAG_EVENT.

Parameters
node the root node of the XML representation of web events.

public void addEventsFromXML (String eventsXML)

This method is 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 TAG_EVENTS or TAG_EVENT.

Parameters
eventsXML the XML representation of web events.

public void appendRemainingEvent (WebEvent event)

Append an remaining event at the end of the remaining events' list.
Such remaining event will be processed at the end.

Parameters
event the WebEvent object.

public 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.

Returns
  • the cloned GenericEventHandler.

public boolean delegateRequest (RequestKeys keys)

The default implementation of this method simply delegates the event to the next source component specified in the static field GenericWebEvent.URL_SOURCE_NAME.

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

public int getHandlerType ()

Returns the type of the current WebEventHandle.

Returns
  • the type of the current event handler.

public String getName ()

Returns the name of this event handler

Returns
  • the name of this event handler

public 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.

public static String getNextSourceName (String currentBeanPath, 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.

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.

Returns
  • a List with the events that were not processed during handleRequest(). If handelRequest() was not invoked, it returns null.

public Class getSupportedWebComponentType ()

Returns the WebComponent class by default. Subclasses should override this to return their respective WebComponent or WebBean int.

Returns
  • the Class of the WebComponent this event handler is associated with.

public WebComponent getWebComponent ()

Returns the WebComponent object associated with the current event handler.

Returns
  • the WebComponent object.

public WebEvent getWebEvent (int eventID)

Returns the specified WebEvent instance which this event handler supports.

Parameters
eventID the event id of the WebEvent.
Returns
  • the specified WebEvent; null if the event is not supported by this event handler.

public Enumeration getWebEvents ()

Returns an enumeration over the WebEvent suppored by this event handler. The WebEvent are returned in no particular order.

Returns
  • an Enumeration over the WebEvent supported.

public 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.

Parameters
keys the RequestKeys object.
Returns
  • an Enumeration over the WebEvent supported.

public boolean handleRequest (RequestKeys keys)

Handles the WebEvent specified in the RequestKeys object. By default, this method will invoke processRequest(RequestKeys) followed by delegateRequest(RequestKeys).

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.

public void processExtraEvents ()

Throws
WebException

public static void processMultipleEvents (String flatState, MultipleEventHandler handler)

public static void processMultipleEvents (String flatState, MultipleEventHandler handler, String componentPath)

Processes multiple events encoded via the FlatStateSerializer.

Parameters
flatState state encoded using the FlatStateSerializer algorithm.
handler event handler to pocess request

public boolean processRequest (RequestKeys keys)

Logic to process the event. Specific event handler implementation extending this class will need to override the default behavior.

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

public void setName (String name)

Sets the name to this event handler

Parameters
name a new name of this event handler

public void setWebComponent (WebComponent component)

Sets a WebComponent instance on this event handler. A WebComponent must maintain a one-one relationship with an event handler instance. After this method call, the WebComponent previously associated with this event handler should have a null instance of WebEventHandler, and the event handler instance previously associate the specified WebComponent should have a null WebComponent.

This method calls the method setWebEventHandler(WebEventHandler). Therefore, any WebComponent implementation should pay attention to avoid cyclic reference to each other between an event handler and a web component.

Parameters
component a new WebComponent object.
Throws
MSTRUncheckedException thrown if component is not an instance of the class returned by getSupportedWebComponentType()

Protected Methods

protected void addEvent (Element eventNode)

This method is 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.

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.

protected WebComponent getEventTarget (RequestKeys keys)

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

Returns
  • the specified WebEvent; null if the event is not supported by this event handler.

protected WebEvent getWebEvent (RequestKeys keys)

Decodes the WebEvent from the RequestKeys.

Parameters
keys request keys
Returns
  • decoded WebEvent

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.

protected boolean isMyEvent (RequestKeys keys)

protected void markInitailized ()

Call this method to mark this event-handler instance as initialized.

protected void setHandlerType (int type)

Sets the type of the current event handler.

Parameters
type the type of the current event handler.

protected void validateRequiredArgument (String argName, String argValue)

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.