Adobe COLDFUSION 9 Manual page 602

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Event handling in a persistent CFC
A persistent CFC can have various methods and if these methods are present, callbacks can be sent on those events to
the CFC. The CFC can then handle these events. In this case, the event for entity persistence comes to the CFC that the
system loads, inserts, updates, or deletes. These methods are:
: This method is called before the load operation or before the data is loaded from the database.
preLoad()
: This method is called after the load operation is complete.
postLoad()
: This method is called just before the object is inserted.
preInsert()
: This method is called after the insert operation is complete.
postInsert()
preUpdate(Struct oldData)
to this method to know the original state of the entity being updated.
: This method is called after the update operation is complete.
postUpdate()
Note: When you call the EntitySave() method on an object that is not loaded using EntityLoad(), it gets updated but
the intercepter call fails. This happens because an empty map is created for the object and there is no previous data
associated with it.
: This method is called before the object is deleted.
preDelete()
: This method is called after the delete operation is complete.
postDelete()
Event handling using an event handler CFC
An application-wide event handler CFC can be defined to handle callback when *any* entity is inserted, updated,
deleted, or retrieved. This CFC must be configured at the application level as an ORM setting:
ormsettings.evenHandler="X.Y.EventHandler"
The event handler CFC needs to implement the
from all persistence-related events and handles them accordingly. In this case, a single CFC handles the events for all
the CFCs.
This interface contains the following methods for the event handler CFC:
For application-wide event handler CFC, you need to specify the component name also along with other arguments.
The methods for application-wide event handler are:
: This method is called before the load operation or before the data is loaded from the database.
preLoad(entity)
: This method is called after the load operation is complete.
postLoad(entity)
: This method is called just before the object is inserted.
preInsert(entity)
: This method is called after the insert operation is complete.
postInsert(entity)
preUpdate(entity, Struct oldData)
data is passed to this method to know the original state of the entity being updated.
Note: When you call the EntitySave() method on an object that is not loaded using EntityLoad(), it gets updated but
the intercepter call fails. This happens because an empty map is created for the object and there is no previous data
associated with it.
: This method is called after the update operation is complete.
postUpdate(entity)
: This method is called before the object is deleted.
preDelete(entity)
: This method is called after the delete operation is complete.
postDelete(entity)
: This method is called just before the object is updated. A struct of old data is passed
CFIDE.ORM.IEventHandler
: This method is called just before the object is updated. A struct of old
Last updated 8/5/2010
interface. This CFC gets the callbacks
597

Advertisement

Table of Contents
loading

Table of Contents