public abstract class

AggregatedEventHandler

extends GenericEventHandler
java.lang.Object
   ↳ com.microstrategy.web.beans.GenericEventHandler
     ↳ com.microstrategy.web.beans.AggregatedEventHandler
Known Direct Subclasses

Class Overview

The AggregatedEventHandler class is intended for customization of existing event handlers. By extending this abstract class, a customized event handler can change the way events are processed, extend the definition of existing events, and create new events.

An instance of this class aggregates a "default" event handler. A custom event handler subclass can either handle a given event itself or delegate it to the aggregated default handler.

Custom event handler subclasses must implement the abstract method processRequest, which serves as the entrypoint for event processing. From there, the custom handler can choose to handle a given event itself, or delegate it by calling handleDefaultRequest.

The default event handler is set via the setDefaultHandler method. Typically, it is not necessary for custom event handler implementations to explicitly call this method. By default, when the system creates an AggregatedEventHandler to be associated with a given bean, it will use the bean's event handler as the default handler (see the example below).

The following code shows a custom event handler that can be associated with a FolderBean:

 public class CustomFolderHandler extends AggregatedEventHandler {
     public boolean processRequest(RequestKeys keys) throws WebException {
         int eventID = getEventID(keys);
         switch (eventID) {
             // handle desired events here
         }

         // or delegate to the default handler
         return handleDefaultRequest(keys);
     }
 }
 
To associate this event handler with a bean, update the bean's <web-bean> node in pageConfig.xml.
Typically, the line in pageConfig.xml that specifies a given bean looks like:
   <web-bean name="fb" persist-mode="2" sys-bean="FolderBean"/>
 
We use the event-handler attribute to associate a custom event handler with that bean:
   <web-bean name="fb" persist-mode="2" sys-bean="FolderBean" event-handler="com.xyz.CustomFolderHandler"/>
 

where com.xyz.CustomFolderHandler is the fully qualified class name of the custom event handler class.

At runtime, when the bean shown above needs to be created, the system will first instantiate a new FolderBean instance. It will then create a new CustomFolderHandler instance that aggregates the FolderBean instance's event handler. Finally, it will call WebComponent.setWebEventHandler to associate the CustomFolderHandler instance with the FolderBean instance.

Summary

[Expand]
Inherited Constants
From class com.microstrategy.web.beans.GenericEventHandler
From interface com.microstrategy.web.beans.WebEventTags
Fields
protected WebEventHandler defaultHandler The default event handler.
[Expand]
Inherited Fields
From class com.microstrategy.web.beans.GenericEventHandler
Protected Constructors
AggregatedEventHandler(int type)
This constructor is deprecated. Use the no-arg constructor, along with setDefaultHandler if necessary. For flexibilty reasons, this class should no longer be responsible for creating the default handler based on its type.
AggregatedEventHandler()
Constructs an AggregatedEventHandler without a default handler.
Public Methods
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.
WebEventHandler getDefaultHandler()
Returns the default event handler.
int getHandlerType()
Returns the event handler type.
Class getSupportedWebComponentType()
Returns the Class type of the WebComponent this event handler is associated with.
WebEvent getWebEvent(int id)
Returns the specified WebEvent instance which this event handler supports.
abstract boolean processRequest(RequestKeys keys)
This method encapsulates the logic to process an incoming event.
void setDefaultHandler(WebEventHandler handler)
Sets the default event handler.
Protected Methods
boolean defaultDelegate(RequestKeys keys)
boolean handleDefaultRequest(RequestKeys keys)
Asks the default event handler to handle the request.
void setHandlerType(int type)
Sets the event handler type.
[Expand]
Inherited Methods
From class com.microstrategy.web.beans.GenericEventHandler
From class java.lang.Object
From interface com.microstrategy.web.beans.WebEventHandler

Fields

protected WebEventHandler defaultHandler

The default event handler.

Protected Constructors

protected AggregatedEventHandler (int type)

This constructor is deprecated.
Use the no-arg constructor, along with setDefaultHandler if necessary. For flexibilty reasons, this class should no longer be responsible for creating the default handler based on its type.

Constructs an AggregatedEventHandler with the specified event handler type. Internally calls setHandlerType, which creates an instance of the event handler with the specified type and sets it to be the default handler.

Parameters
type the event handler type.

protected AggregatedEventHandler ()

Constructs an AggregatedEventHandler without a default handler. Code that creates an AggregatedEventHandler instance programmatically can call setDefaultHandler to set the default handler.

Public Methods

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 WebEventHandler getDefaultHandler ()

Returns the default event handler.

Returns
  • WebEventHandler The default event handler, or null if no default event handler has been set.

public int getHandlerType ()

Returns the event handler type. This implementation simply returns the default handler's type.

Returns
  • the event handler type.

public Class getSupportedWebComponentType ()

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

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

public WebEvent getWebEvent (int id)

Returns the specified WebEvent instance which this event handler supports.

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

public abstract boolean processRequest (RequestKeys keys)

This method encapsulates the logic to process an incoming event. Normally, this is invoked by handleRequest(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 setDefaultHandler (WebEventHandler handler)

Sets the default event handler.

Parameters
handler A WebEventHandler instance to use as the default event handler.

Protected Methods

protected boolean defaultDelegate (RequestKeys keys)

Throws
WebException

protected boolean handleDefaultRequest (RequestKeys keys)

Asks the default event handler to handle the request.

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

protected void setHandlerType (int type)

Sets the event handler type. This implementation creates a new instance of the event handler with the specified type and sets it to be the default handler. Can be overridden in subclasses to change the way default handlers are created.

NOTE: This implementation is provided for backward compatibility only. New code should set the default handler using setDefaultHandler.

Parameters
type the event handler type.