Package com.microstrategy.web.beans
Class GenericEventHandler
- java.lang.Object
-
- com.microstrategy.web.beans.GenericEventHandler
-
- All Implemented Interfaces:
WebEventHandler
,WebEventTags
,java.lang.Cloneable
- Direct Known Subclasses:
AggregatedEventHandler
,SysEventHandler
public class GenericEventHandler extends java.lang.Object implements WebEventHandler, WebEventTags, java.lang.Cloneable
This class provides the default implementation of the interface WebEventHandler.The
clone
method provides a shallow cloning of the contained collection ofWebEvent
, as well as the associatedWebComponent
.- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GenericEventHandler.GenericEventKeys
This inner class is an implementation of the request keys specific for an event.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<WebEvent>
_extraEvents
protected int
layerOfHandleRequest
static java.lang.String
MULTIPLE_EVENT_SOURCE_SUFFIX
static int
NO_EVENT_ID
This constant represents the ID returned by the getEventID method when there is no event in the request-
Fields inherited from interface com.microstrategy.web.beans.WebEventTags
ATT_ARGUMENT_ENUMERATOR, ATT_ARGUMENT_ID, ATT_ARGUMENT_INDEX, ATT_ARGUMENT_NAME, ATT_ARGUMENT_REQUIRED, ATT_ARGUMENT_TYPE, ATT_ARGUMENT_VALIDATOR, ATT_ARGUMENT_VALUE, ATT_EVENT_DEPRECATED, ATT_EVENT_ENUMERATOR, ATT_EVENT_HANDLER_ENUMERATOR, ATT_EVENT_HANDLER_NAME, ATT_EVENT_HANDLER_TYPE, ATT_EVENT_ID, ATT_EVENT_NAME, ATT_EVENT_TARGET, TAG_ARGUMENT, TAG_ARGUMENTS, TAG_EVENT, TAG_EVENT_HANDLER, TAG_EVENT_HANDLERS, TAG_EVENTS
-
-
Constructor Summary
Constructors Constructor Description GenericEventHandler()
Constructs aGenericEventHandler
with empty collection of WebEvent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addEvent(WebEvent event)
Adds aWebEvent
instance into the current event handler.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 Editorvoid
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 Editorstatic void
addEventsFromRequestKeys(java.util.ArrayList eventList, RequestKeys keys, WebComponent component, SimpleList filterEventIDList)
void
addEventsFromXML(java.lang.String eventsXML)
Deprecated.The GenericEventHandler is not responsible to read the xml structure, therefore this method is not used anymore.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.java.lang.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 fieldGenericWebEvent.URL_SOURCE_NAME
.protected static int
getEventID(RequestKeys keys)
Retrieves the event id passed in from theRequestKeys
.protected WebComponent
getEventTarget(RequestKeys keys)
int
getHandlerType()
Returns thetype
of the currentWebEventHandle
.java.lang.String
getName()
Returns the name of this event handlerjava.lang.String
getNextSourceName(RequestKeys keys)
Returns the next component name in the event component path.static java.lang.String
getNextSourceName(java.lang.String currentBeanPath, java.lang.String eventFullPath)
Returns the next source component which will handle the event.static SimpleList
getOrderedEvents(RequestKeys keys, java.lang.String errorDesc)
SimpleList
getPendingEvents()
Returns the list of events that were not processed.java.lang.Class
getSupportedWebComponentType()
Returns theWebComponent
class by default.WebComponent
getWebComponent()
Returns theWebComponent
object associated with the current event handler.WebEvent
getWebEvent(int eventID)
Returns the specifiedWebEvent
instance which this event handler supports.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 parameterprotected WebEvent
getWebEvent(RequestKeys keys)
Decodes theWebEvent
from theRequestKeys
.java.util.Enumeration
getWebEvents()
Returns an enumeration over theWebEvent
suppored by this event handler.java.util.Enumeration
getWebEventsFromRequest(RequestKeys keys)
Returns an enumeration over theWebEvent
suppored by this event handler that are present in the request keys provided.boolean
handleRequest(RequestKeys keys)
Handles theWebEvent
specified in theRequestKeys
object.protected boolean
isInitialized()
Returnstrue
after themarkInitailized()
has been called.protected boolean
isMyEvent(RequestKeys keys)
protected void
markInitailized()
Call this method to mark this event-handler instance as initialized.void
processExtraEvents()
static void
processMultipleEvents(java.lang.String flatState, com.microstrategy.web.beans.MultipleEventHandler handler)
Deprecated.static void
processMultipleEvents(java.lang.String flatState, com.microstrategy.web.beans.MultipleEventHandler handler, java.lang.String componentPath)
Processes multiple events encoded via theFlatStateSerializer
.boolean
processRequest(RequestKeys keys)
Logic to process the event.protected void
setHandlerType(int type)
Sets thetype
of the current event handler.void
setName(java.lang.String name)
Sets the name to this event handlervoid
setWebComponent(WebComponent component)
Sets aWebComponent
instance on this event handler.protected void
validateRequiredArgument(java.lang.String argName, java.lang.String argValue)
A helper method which ensures that theargValue
corresponding toargName
is not null and not empty.
-
-
-
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
-
-
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
-
getWebComponent
public WebComponent getWebComponent()
Returns theWebComponent
object associated with the current event handler.- Specified by:
getWebComponent
in interfaceWebEventHandler
- Returns:
- the WebComponent object.
-
setWebComponent
public void setWebComponent(WebComponent component) throws MSTRUncheckedException
Sets aWebComponent
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 ofWebEventHandler
, and the event handler instance previously associate the specifiedWebComponent
should have a nullWebComponent
.This method calls the method
WebComponent.setWebEventHandler(com.microstrategy.web.beans.WebEventHandler)
. Therefore, anyWebComponent
implementation should pay attention to avoid cyclic reference to each other between an event handler and a web component.- Specified by:
setWebComponent
in interfaceWebEventHandler
- Parameters:
component
- a new WebComponent object.- Throws:
MSTRUncheckedException
- thrown if component is not an instance of the class returned bygetSupportedWebComponentType()
-
getWebEvent
public WebEvent getWebEvent(int eventID)
Returns the specifiedWebEvent
instance which this event handler supports.- Specified by:
getWebEvent
in interfaceWebEventHandler
- 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 theWebEvent
from theRequestKeys
.- Parameters:
keys
- request keys- Returns:
- decoded
WebEvent
-
handleRequest
public boolean handleRequest(RequestKeys keys) throws WebException
Handles theWebEvent
specified in theRequestKeys
object. By default, this method will invokeprocessRequest(RequestKeys)
followed bydelegateRequest(RequestKeys)
.- Specified by:
handleRequest
in interfaceWebEventHandler
- 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.
-
processExtraEvents
public void processExtraEvents() throws WebException
- Throws:
WebException
-
addEventsFromRequestKeys
public static void addEventsFromRequestKeys(java.util.ArrayList eventList, RequestKeys keys, WebComponent component, SimpleList filterEventIDList)
-
getOrderedEvents
public static SimpleList getOrderedEvents(RequestKeys keys, java.lang.String errorDesc) throws WebException
- Throws:
WebException
-
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 interfaceWebEventHandler
- 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)
Deprecated.- Parameters:
flatState
-handler
-
-
processMultipleEvents
public static void processMultipleEvents(java.lang.String flatState, com.microstrategy.web.beans.MultipleEventHandler handler, java.lang.String componentPath)
Processes multiple events encoded via theFlatStateSerializer
.- Parameters:
flatState
- state encoded using theFlatStateSerializer
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 fieldGenericWebEvent.URL_SOURCE_NAME
.- Specified by:
delegateRequest
in interfaceWebEventHandler
- 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 segementcurrentBeanPath
in theeventFullPath
. For example, if
then this method returnsString currentBeanPath = "servlet.page"; String eventFullPath = "servlet.page.bean1.bean2";
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 EditorAdds one or moreGenericWebEvent
into the current event handler. The root node of event definition XML passed in might be eitherWebEventTags.TAG_EVENTS
orWebEventTags.TAG_EVENT
.- Specified by:
addEventsFromXML
in interfaceWebEventHandler
- 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 EditorAdds one or moreGenericWebEvent
into the current event handler. The root node of event definition XML passed in might be eitherWebEventTags.TAG_EVENTS
orWebEventTags.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 EditorAdd oneGenericWebEvent
into the current event handler.- Parameters:
eventNode
- the root node of a single event.- See Also:
WebEventHandlerFactory
-
addEvent
public void addEvent(WebEvent event)
Adds aWebEvent
instance into the current event handler.- Specified by:
addEvent
in interfaceWebEventHandler
- Parameters:
event
- theWebEvent
instance to be added.
-
getHandlerType
public int getHandlerType()
Returns thetype
of the currentWebEventHandle
.- Specified by:
getHandlerType
in interfaceWebEventHandler
- Returns:
- the type of the current event handler.
-
getEventID
protected static int getEventID(RequestKeys keys)
Retrieves the event id passed in from theRequestKeys
.- Parameters:
keys
- theRequestKeys
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 thetype
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 associatedWebComponent
are not deeply cloned.- Overrides:
clone
in classjava.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 theargValue
corresponding toargName
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 theWebEvent
suppored by this event handler. TheWebEvent
are returned in no particular order.- Specified by:
getWebEvents
in interfaceWebEventHandler
- Returns:
- an Enumeration over the
WebEvent
supported.
-
getWebEventsFromRequest
public java.util.Enumeration getWebEventsFromRequest(RequestKeys keys)
Returns an enumeration over theWebEvent
suppored by this event handler that are present in the request keys provided. TheWebEvent
are returned in no particular order.- Specified by:
getWebEventsFromRequest
in interfaceWebEventHandler
- Parameters:
keys
- theRequestKeys
object.- Returns:
- an Enumeration over the
WebEvent
supported.
-
getSupportedWebComponentType
public java.lang.Class getSupportedWebComponentType()
Returns theWebComponent
class by default. Subclasses should override this to return their respectiveWebComponent
orWebBean
int.- Specified by:
getSupportedWebComponentType
in interfaceWebEventHandler
- Returns:
- the
Class
of theWebComponent
this event handler is associated with.
-
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 interfaceWebEventHandler
- Returns:
- a List with the events that were not processed during
handleRequest()
. IfhandelRequest()
was not invoked, it returns null.
-
getEventTarget
protected WebComponent getEventTarget(RequestKeys keys)
- Since:
- MicroStrategy Web 8.0.2
-
isInitialized
protected boolean isInitialized()
Returnstrue
after themarkInitailized()
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 interfaceWebEventHandler
- Parameters:
event
- theWebEvent
object.
-
-