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
clonemethod 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 classGenericEventHandler.GenericEventKeysThis 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>_extraEventsprotected intlayerOfHandleRequeststatic java.lang.StringMULTIPLE_EVENT_SOURCE_SUFFIXstatic intNO_EVENT_IDThis 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 aGenericEventHandlerwith empty collection of WebEvent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEvent(WebEvent event)Adds aWebEventinstance into the current event handler.protected voidaddEvent(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 EditorvoidaddEvents(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 voidaddEventsFromRequestKeys(java.util.ArrayList eventList, RequestKeys keys, WebComponent component, SimpleList filterEventIDList)voidaddEventsFromXML(java.lang.String eventsXML)Deprecated.The GenericEventHandler is not responsible to read the xml structure, therefore this method is not used anymore.voidappendRemainingEvent(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.Objectclone()Clone the current event handler instance.booleandelegateRequest(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 intgetEventID(RequestKeys keys)Retrieves the event id passed in from theRequestKeys.protected WebComponentgetEventTarget(RequestKeys keys)intgetHandlerType()Returns thetypeof the currentWebEventHandle.java.lang.StringgetName()Returns the name of this event handlerjava.lang.StringgetNextSourceName(RequestKeys keys)Returns the next component name in the event component path.static java.lang.StringgetNextSourceName(java.lang.String currentBeanPath, java.lang.String eventFullPath)Returns the next source component which will handle the event.static SimpleListgetOrderedEvents(RequestKeys keys, java.lang.String errorDesc)SimpleListgetPendingEvents()Returns the list of events that were not processed.java.lang.ClassgetSupportedWebComponentType()Returns theWebComponentclass by default.WebComponentgetWebComponent()Returns theWebComponentobject associated with the current event handler.WebEventgetWebEvent(int eventID)Returns the specifiedWebEventinstance which this event handler supports.protected WebEventgetWebEvent(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 WebEventgetWebEvent(RequestKeys keys)Decodes theWebEventfrom theRequestKeys.java.util.EnumerationgetWebEvents()Returns an enumeration over theWebEventsuppored by this event handler.java.util.EnumerationgetWebEventsFromRequest(RequestKeys keys)Returns an enumeration over theWebEventsuppored by this event handler that are present in the request keys provided.booleanhandleRequest(RequestKeys keys)Handles theWebEventspecified in theRequestKeysobject.protected booleanisInitialized()Returnstrueafter themarkInitailized()has been called.protected booleanisMyEvent(RequestKeys keys)protected voidmarkInitailized()Call this method to mark this event-handler instance as initialized.voidprocessExtraEvents()static voidprocessMultipleEvents(java.lang.String flatState, com.microstrategy.web.beans.MultipleEventHandler handler)Deprecated.static voidprocessMultipleEvents(java.lang.String flatState, com.microstrategy.web.beans.MultipleEventHandler handler, java.lang.String componentPath)Processes multiple events encoded via theFlatStateSerializer.booleanprocessRequest(RequestKeys keys)Logic to process the event.protected voidsetHandlerType(int type)Sets thetypeof the current event handler.voidsetName(java.lang.String name)Sets the name to this event handlervoidsetWebComponent(WebComponent component)Sets aWebComponentinstance on this event handler.protected voidvalidateRequiredArgument(java.lang.String argName, java.lang.String argValue)A helper method which ensures that theargValuecorresponding toargNameis 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 theWebComponentobject associated with the current event handler.- Specified by:
getWebComponentin interfaceWebEventHandler- Returns:
- the WebComponent object.
-
setWebComponent
public void setWebComponent(WebComponent component) throws MSTRUncheckedException
Sets aWebComponentinstance 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 specifiedWebComponentshould have a nullWebComponent.This method calls the method
WebComponent.setWebEventHandler(com.microstrategy.web.beans.WebEventHandler). Therefore, anyWebComponentimplementation should pay attention to avoid cyclic reference to each other between an event handler and a web component.- Specified by:
setWebComponentin 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 specifiedWebEventinstance which this event handler supports.- Specified by:
getWebEventin 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 theWebEventfrom theRequestKeys.- Parameters:
keys- request keys- Returns:
- decoded
WebEvent
-
handleRequest
public boolean handleRequest(RequestKeys keys) throws WebException
Handles theWebEventspecified in theRequestKeysobject. By default, this method will invokeprocessRequest(RequestKeys)followed bydelegateRequest(RequestKeys).- Specified by:
handleRequestin 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:
processRequestin 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
@Deprecated 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 theFlatStateSerializeralgorithm.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:
delegateRequestin interfaceWebEventHandler- Parameters:
keys- the RequestKeys object containing event ID, sources, and any other information.- Returns:
- true if handling succeeds in
processRequestor 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 segementcurrentBeanPathin theeventFullPath. For example, if
then this method returnsString currentBeanPath = "servlet.page"; String eventFullPath = "servlet.page.bean1.bean2";bean1to 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
@Deprecated 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 moreGenericWebEventinto the current event handler. The root node of event definition XML passed in might be eitherWebEventTags.TAG_EVENTSorWebEventTags.TAG_EVENT.- Specified by:
addEventsFromXMLin interfaceWebEventHandler- Parameters:
eventsXML- the XML representation of web events.- See Also:
WebEventHandlerFactory
-
addEvents
@Deprecated 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 moreGenericWebEventinto the current event handler. The root node of event definition XML passed in might be eitherWebEventTags.TAG_EVENTSorWebEventTags.TAG_EVENT.- Parameters:
node- the root node of the XML representation of web events.- See Also:
WebEventHandlerFactory
-
addEvent
@Deprecated 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 oneGenericWebEventinto the current event handler.- Parameters:
eventNode- the root node of a single event.- See Also:
WebEventHandlerFactory
-
addEvent
public void addEvent(WebEvent event)
Adds aWebEventinstance into the current event handler.- Specified by:
addEventin interfaceWebEventHandler- Parameters:
event- theWebEventinstance to be added.
-
getHandlerType
public int getHandlerType()
Returns thetypeof the currentWebEventHandle.- Specified by:
getHandlerTypein 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- theRequestKeysobject.- Returns:
- the ID of the event to be handled; -1
NO_EVENT_IDif the request does not contain any event ID.
-
setHandlerType
protected void setHandlerType(int type)
Sets thetypeof 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 associatedWebComponentare not deeply cloned.- Overrides:
clonein classjava.lang.Object- Returns:
- the cloned
GenericEventHandler.
-
validateRequiredArgument
protected void validateRequiredArgument(java.lang.String argName, java.lang.String argValue) throws WebExceptionA helper method which ensures that theargValuecorresponding toargNameis 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 theWebEventsuppored by this event handler. TheWebEventare returned in no particular order.- Specified by:
getWebEventsin interfaceWebEventHandler- Returns:
- an Enumeration over the
WebEventsupported.
-
getWebEventsFromRequest
public java.util.Enumeration getWebEventsFromRequest(RequestKeys keys)
Returns an enumeration over theWebEventsuppored by this event handler that are present in the request keys provided. TheWebEventare returned in no particular order.- Specified by:
getWebEventsFromRequestin interfaceWebEventHandler- Parameters:
keys- theRequestKeysobject.- Returns:
- an Enumeration over the
WebEventsupported.
-
getSupportedWebComponentType
public java.lang.Class getSupportedWebComponentType()
Returns theWebComponentclass by default. Subclasses should override this to return their respectiveWebComponentorWebBeanint.- Specified by:
getSupportedWebComponentTypein interfaceWebEventHandler- Returns:
- the
Classof theWebComponentthis 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:
getPendingEventsin 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()
Returnstrueafter 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:WebEventHandlerAppend an remaining event at the end of the remaining events' list.
Such remaining event will be processed at the end.- Specified by:
appendRemainingEventin interfaceWebEventHandler- Parameters:
event- theWebEventobject.
-
-