EventMap

A fundamental part of Mate is the EventMap tag. It allows you define mappings for the events that your application creates. It is basically a collection of EventHandlers blocks, where each block matches an event type.

<EventMap>
   ...event handler lists here...
</EventMap>

The EventMap also serves as the mapping for Injectors.

The EventMap tag doesn't have any attribute, but its importance lies in the tags in can contain.

Inner tags

EventHandlers

The event map contains an EventHandlers block for every event that you want to listen to. Each block is executed every time an event of the type specified is dispatched. Blocks are defined by using the EventHandlers tag.

<EventMap xmlns="http://mate.asfusion.com/">

   <EventHandlers type="myEventType">
      ... here what you want to happen when this event is dispatched...
   </EventHandlers>
   
   <EventHandlers type="myOtherEventType">
      ... here what you want to happen when this other event is dispatched...
   </EventHandlers>
   
</EventMap>

See EventHandlers for more information.

MessageHandlers

In addition to EventHandlers blocks, an event map can also contain MessageHandlers blocks. A block of MessageHandlers will be executed when a given Flex Messaging Service message is received. For the sequence to run, you must specify the same attributes you would in an <mx:Consumer> tag, so that when a message is received by the application, it is routed to the correct MessageHandler.

See MessageHandlers for more information.

An event map may contain any combination of EventHandlers and MessageHandlers tags:

<EventMap xmlns="http://mate.asfusion.com/">

   <MessageHandlers destination="ColdFusionGateway">
      ... here what you want to happen when this message is received ...
   </MessageHandlers>

</EventMap>

Injectors

Actions listed inside an Injectors block will be executed when an object of the class defined in the target attribute is created.

<EventMap xmlns="http://mate.asfusion.com/">

   <Injectors target="{MyTargetClass}">
      ... here what you want to happen when an instance of MyTargetClass is created ...
   </Injectors>
</EventMap>

0 responses so far

  1. I'm wondering if the Debugger and Injectors tag should be covered in this page since they are inner tags of the EventMap.
  2. Eric,
    Yes, the Injectors tag should be covered, but not the Debugger tag, since the Debugger tag can be placed anywhere, and many times it is added to the main Application file instead.
  3. One little thing has been bothering me with the examples.

    When you want to signal Mate from a business object - such as PhotoCoordinator.as in the Flickr Widget example - you dispatch events from these managers - done by using a local dispatcher, formed via ObjectBuilder and the scope.dispatcher argument in the EventMap.

    Is there or will there be a way to setup a "Watcher" - that can watch a property from a business object and announce an event when it changes?
  4. Hi Justin,
    Please ask that question in the forums.
    Thanks!

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!

Leave this field empty