28.3. Event Generators

Another one of the major features of the Cairngorm Extensions is the ability to generate events via a class called the EventGenerator. This is conceptually similar to the SequenceCommand class from the Cairngorm framework (Chapters 7 and 24) in that it enables you to specify a chain of logic. However, the EventGenerator class goes beyond the capabilities of the SequenceCommand class in that it enables you to specify a sequence of events that can then be triggered in series or parallel and do not require any special implementation in the command classes.

The source code for the EventGenerator class (com.universalmind.cairngorm.events.generator) contains the following example of an EventGenerator implemented in MXML:

<generator:EventGenerator id="startUpEvents"
xmlsn:generator="com.universalmind.cairngorm.events.generator.*">
  <generator:EventGenerator trigger="sequence" result="onUserLoaded(event);" >
      <events:LoadResourcesEvent
xmlsn:events="com.mercer.mercerOnline.control.events.*" /> <events:GetLoggedInUserEvent xmlsn:events="com.mercer.mercerOnline.control.events.login.*" /> <events:LoadClassesOfBusinessEvent xmlsn:events="com.mercer.mercerOnline.control.events.questionnaire.*"/> </generator:EventGenerator> <generator:EventGenerator trigger="parallel"> <events:LoadRolesForFeaturesEvent xmlsn:events="com.mercer.mercerOnline.control.events.login.*" /> <events:LoadAssociatedUsersEvent xmlsn:events="com.mercer.common.control.events.*" /> </generator:EventGenerator> ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.