Using events for inter-model communication

Related Topics ...

Overview: Communicating Between Models

Using Linked Java Objects for Inter-Model Communication

Using the Session for Inter-Model Communication

Using Linked Models for Inter-Model Communication

Events are named broadcasts which arrive at any model in the session (i.e. for same user) that is listening for them. An Event can be declared to have arguments, and the values are specified when the Event is fired. It is important that all users of a given Event declare it the same way.

The recommendation is to put your Event Declaration builders in a single model and then import that model into any others that want to fire or handle the events.  Events are named broadcasts across the session. Any other Model that the same user is running at the time the event is fired can catch that event.  

When you include an Event Declaration builder in a model, either directly or through an Imported Model Builder, the Builder will create, in your WebApp, a method called fireXxx, where Xxx is the event name. This method will have the correct arguments, as defined in the Event Declaration Builder.

To handle an Event, create a method with the same arguments as the Event Declaration and then create an Event Handler Builder to tell the system to route that named Event to that method. Once your model is instantiated, then it will be listening for any model (including your own) that fires that event. Events are a good technique for communication when you know that a certain model (or type of model) exists, but you don't have a direct link to it.