Skip to content
Jeroen Knoef edited this page Oct 8, 2013 · 7 revisions

At the beginning of the request handling cycle, an Event object is created. All tasks defined for the event, and all events that are dispatched during the cycle, receive this same Event instance. This one Event instance is your companion during the request.

An exception to this rule happens in the case of threads. CFlow has built-in support for threads, by means of the <thread> tag in the configuration. A thread receives a copy of the event object for thread safety. When the thread finishes and is configured to join the page thread, the thread's event object is merged with the original event object (in the page thread), where items on the page thread's event object are never overwritten.

You use the Event object just like a struct in the event handlers in your controllers, to pass information on to subsequent tasks. The object itself is not passed to view templates. Views only receive the properties struct (merged with their variables scope), obtained with getProperties().

The Event object has the following methods:

string getTarget()

Returns the current target of the event. That is, it returns the target of the event that is currently being handled. If you need the original target (the one that the cycle started out with), use getOriginalTarget().

string getType()

Returns the current event type. The original type is available using getOriginalType().

string getOriginalTarget()

Returns the target that started the request cycle.

string getOriginalType()

Returns the event type that started the request cycle.

void cancel()

Cancels the event, and stops subsequent task execution for this event.

boolean isCanceled()

Returns whether or not the event is canceled.

void reset()

Resets the canceled state of the event.

struct getProperties()

Returns a struct containing all the data that is put on the object.

void setProperties(required struct)

Appends the data in the struct on the object. Existing data is not overwritten. You probably rarely need this method. Putting single properties on the object is most easily done by treating the object as a struct.

void abort()

Aborts event execution. This does not abort the request, control is given back to the caller (usually Application.cfc).

boolean willRejoin()

Applicable to tasks that run within a thread (defined with <thread>). Returns true if the thread will rejoin the page thread by means of a join action (or if it is the page thread itself). If a join action expires (or if no join action is issued), this method returns false.

Clone this wiki locally