MicroStrategy ONE
Event and Event Handler Interfaces
Events represent user actions that are processed by event handlers. This topic describes the interfaces for both events and event handlers.
-
WebEvent interface
The WebEvent interface is implemented by the GenericWebEvent class.
-
WebEventHandler interface
The WebEventHandler interface is implemented by the GenericEventHandler class.
Every user response in MicroStrategy Web corresponds to a unique WebEvent, and every WebEvent is handled by a specific WebEventHandler.
WebEvent interface
WebEvents can be used in transforms and are processed by event handlers. When they are used in transforms, WebEvents generate HTML representations of themselves— in the form of links or menu options, for example. These HTML representations allow users to perform actions on their browsers— such as clicking a particular link or choosing a specific menu option— that generate requests for MicroStrategy Web events. When a user performs such an action, the request that is generated contains the information needed to create the related WebEvent. The associated WebEventHandler uses the information in the request to create the appropriate WebEvent and process it.
Processing events with event handlers
The WebEvent interface provides access to several important methods that are used when events are processed by event handlers:
-
getID()
This method returns the unique identifier for an event. This method allows you to perform specific actions based on specific event IDs.
-
getArgumentName(), getArgumentValue(), getArguments()
These methods allow you to retrieve and handle the arguments and argument values for an event.
Rendering links that call events in transforms
Transforms can render output that includes interactive links, which allow users to call specific events. These events are created in the transform and then the Parameter Builder infrastructure is used to generate part or all of the URL links that call the events from a Web browser.
Transforms can render multiple events. For each event, the transform calls the getWebEvent(eventType) method of the WebEventHandler interface to retrieve the event. If the event is supported, the transform renders it; otherwise, it returns NULL. In either case, the transform continues to call the getWebEvent(eventType) method until it has retrieved all of the events.
WebEventHandler interface
By default, every event handler in MicroStrategy Web products is a GenericEventHandler— that is, the WebEventHandler interface is implemented by the GenericEventHandler class. The GenericEventHandler class provides access to several important methods:
-
getWebEvent()
This method returns the WebEvent corresponding to the specified event ID.
-
getHandlerType()
This method returns the event-handler type of the current WebEventHandler. All of the event-handler types supported in the SDK layer are listed in EnumEventHandlerTypes.
-
processRequest()
This method is called when the event handler is invoked by the application Controller to handle an event, and it contains the logic to process that event. It is the main method in any event handler. This method returns true if the event is successfully processed; it returns false if the event is ignored and not processed.
Customizing events by aggregating event-handlers
The way to customize events is to extend the functionality of MicroStrategy Web event-handlers by aggregating them. You can build a custom event-handler by extending the AggregatedEventHandler class. Extending the AggregatedEventHandler abstract class allows a customized event handler to extend the definition of existing events, create new events, and create new event handlers of an existing type. The AggregatedEventHandler class extends the GenericEventHandler class and provides access to the handleDefaultRequest() method, which is used by the customized event handler to delegate an event to an aggregated default event handler compatible with the customized event handler, if the customized event handler decides not to handle the event.
For instances such as creating a new custom bean where aggregation is not required, you can use GenericEventHandler.