java.lang.Object | ||
↳ | com.microstrategy.web.beans.GenericEventHandler | |
↳ | com.microstrategy.web.beans.AggregatedEventHandler |
![]() |
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
.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.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected WebEventHandler | defaultHandler | The default event handler. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
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.
type | the event handler type. |
---|
Constructs an AggregatedEventHandler
without a default
handler. Code that creates an AggregatedEventHandler
instance programmatically can call
setDefaultHandler
to set the default handler.
The default implementation of this method simply delegates the event to
the next source component specified in the static field
GenericWebEvent.URL_SOURCE_NAME
.
keys | the RequestKeys object containing event ID, sources, and any other information. |
---|
processRequest
or one of its children.WebException |
---|
Returns the default event handler.
Returns the event handler type. This implementation simply returns the default handler's type.
Returns the Class
type of the WebComponent
this event
handler is associated with.
Class
of the WebComponent
this event
handler is associated with.Returns the specified WebEvent
instance which this event handler
supports.
id | the event id of the WebEvent. |
---|
This method encapsulates the logic to process an incoming event.
Normally, this is invoked by handleRequest(RequestKeys)
.
keys | the RequestKeys object containing event ID, sources, and any other information. |
---|
WebException | thrown if handling of the request fails. |
---|
Sets the default event handler.
handler | A WebEventHandler instance to use as the default
event handler. |
---|
Asks the default event handler to handle the request.
keys | the RequestKeys object containing event ID, sources, and any other information. |
---|
true
if handling succeeds; false if the event is
ignored and not handled.WebException |
---|
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
.
type | the event handler type. |
---|