Skip to content
neoneo edited this page Jun 18, 2012 · 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 a properties struct, obtained with getProperties().

The Event object has the following methods:

string getTarget()

Returns the target of the event.

string getType()

Returns the event type.

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.

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