Actions

Description

JEvent

From Joomla! Documentation

Revision as of 12:29, 17 April 2011 by Chris Davenport (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

JEvent is a an abstract class for the definition of event handlers. Together with the JDispatcher class, it implements the base functionality for the Event-Dispatcher design pattern. JEvent needs to be extended by a concrete event handler class, that implements the functionality that will be triggered once an event occurs.

The Event-Dispatcher-Pattern

The Joomla Framework is divided into different tiers (See: Framework). The idea is that business logic and information of one part of the application are encapsulated, so they can be changed, and replaced without affecting other parts of the application. Sometimes however, you need to access information from other parts of the application. The Registry pattern can help you with that (See: JRegistry). And sometimes you want other parts of the application to be automatically informed, once an event anywhere within the application occurs. This is where the Event-Dispatcher-Pattern comes into play.

The pattern allows you to register event-handlers for a certain event at a global event-dispatcher. Once the event occures, the event-dispatcher calls all event-handlers that handle that certain event and passes a set of arguments to it.