Hi Matt

Thanks for your reply. I am following a book by John Whish "ColdFusion ORM" and 
have pasted his exmaple;

component implements="cfide.orm.IEventHandler"
{
public void function preLoad( any entity )
{
logEvent( "preload", arguments.entity );
}
public void function postLoad( any entity )
{
logEvent( "postload", arguments.entity );
}
public void function preInsert( any entity )
{
logEvent( "preinsert", arguments.entity );
var timestamp = now();
if ( StructKeyExists( arguments.entity, "setCreated" ) )
{
arguments.entity.setcreated( timestamp );
}
if ( StructKeyExists( arguments.entity, "setUpdated" ) )
{
arguments.entity.setupdated( timestamp );
}
}
public void function postInsert( any entity )
{
logEvent( "postinsert", arguments.entity );
}
public void function preUpdate( any entity, Struct oldData )
{
if ( StructKeyExists( arguments.entity, "setUpdated" ) )
{
arguments.entity.setupdated( Now() );
}
logEvent( "preupdate", arguments.entity );
}
public void function postUpdate( any entity )
{
logEvent( "postupdate", arguments.entity );
}
public void function preDelete( any entity )
{
logEvent( "predelete", arguments.entity );
}
public void function postDelete( any entity )
{
logEvent( "postdelete", arguments.entity );
}
private void function logEvent( required string event, required
CFC )
{
var message = "Entity: #getMetaData( cfc ).fullname#, Event:
#event#";
WriteLog( type="event", file="ormevent.log", text=message );
}
} 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349251
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to