Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ormsettings.eventHandler
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bernhard Döbler  
View profile  
 More options Jun 28 2011, 4:09 pm
From: Bernhard Döbler <bard...@gmail.com>
Date: Tue, 28 Jun 2011 22:09:28 +0200
Local: Tues, Jun 28 2011 4:09 pm
Subject: ormsettings.eventHandler
Hi,

I'd like to have a CFC handling ORM events setting updated-timestamps
on update and the like.

I keep getting the error:
ormcfcs.ormeventhandler is not a valid ORM event handler.
It must implement interface cfide.orm.IEventHandler

in my Application.cfc I defined
        <cfset this.ormsettings.eventHandling = true>
        <cfset this.ormsettings.eventHandler="ormcfcs.ormeventhandler">
        <cfset this.ormsettings.cfclocation = "/ormcfcs/">

and put the following ormeventhandler.cfc in the ormcfcs folder

<cfcomponent implements="CFIDE.orm.IEventHandler">

        <cffunction name="preInsert" access="public" returntype="void"
output="false" hint="I run before this entity is inserted.">
                <cfargument name="entity" type="any" />

                <!---
                Set the date/time properties. This way, we can
                keep track of the time at which this object was
                created / inserted.
                --->
                <cfset this.setangelegt_datum( Now() ) />
                <cfset this.setgeaendert_datum( Now() ) />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="postLoad" access="public" returntype="void"
output="false" hint="I run after this entity is loaded.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="postDelete" access="public" returntype="void"
output="false" hint="I run after this entity is deleted.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="preLoad" access="public" returntype="void"
output="false" hint="I run before this entity is loaded.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="preDelete" access="public" returntype="void"
output="false" hint="I run before this entity is deleted.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="preUpdate" access="public" returntype="void"
output="false" hint="I run before this entity is updated.">
                <cfargument name="entity" type="any" />
                <!--- Define the arguments. --->
                <cfargument name="oldData" type="struct" required="true" hint="I am
the collection of data held over from the load time." />

                <!---
                Set the date/time properties. This way, we can
                keep track of the most recent time at which this
                object was updated.
                --->
                <cfset this.setgeaendert_datum( Now() ) />

                <!---
                Return out. NOTE: If this method return TRUE, then
                the update is cancelled.
                --->
                <cfreturn />
        </cffunction>

        <cffunction name="postUpdate" access="public" returntype="void"
output="false" hint="I run after this entity is updated.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

        <cffunction name="postInsert" access="public" returntype="void"
output="false" hint="I run before this entity is inserted.">
                <cfargument name="entity" type="any" />

                <!--- Return out. --->
                <cfreturn />
        </cffunction>

</cfcomponent>

It works, when I use the following cfc in script-notation.

component implements="CFIDE.orm.IEventHandler" {

        public void function preInsert(any entity){
                arguments.entity.setangelegt_datum(now());
                arguments.entity.setgeaendert_datum(now());
        }

        public void function postLoad( any entity){
                arguments.entity.setgeaendert_datum(now());
        }

        public void function postDelete(any entity){

        }

        public void function preLoad( any entity){

        }

        public void function preDelete( any entity) {

        }

        public void function preUpdate( any entity, Struct oldData){

        }

        public void function postUpdate( any entity){

        }

        public void function postInsert( any entity){

        }

}

Are you using ORM events to modify data preUpdate? Have you used
mappedSuperClass to define event handlers?

Best,
Bernhard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Kotek  
View profile  
 More options Jun 28 2011, 6:24 pm
From: Brian Kotek <brian...@gmail.com>
Date: Tue, 28 Jun 2011 18:24:18 -0400
Local: Tues, Jun 28 2011 6:24 pm
Subject: Re: [cf-orm-dev] ormsettings.eventHandler

I'm not sure why the script version works and the tag-based one doesn't, and
it would probably be good to find out. But as a pragmatist, I'd say just use
the script version since it is vastly superior to the tag version in terms
of layout, space, and ease of scanning.

Also, mapped superclass only applies to ORM CFCs. While the event handler
CFCs are used as part of the ORM framework, they are not entities. So you'd
just use normal inheritance here.

Brian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Nelson  
View profile  
 More options Jun 28 2011, 8:19 pm
From: Tony Nelson <tonynelso...@gmail.com>
Date: Tue, 28 Jun 2011 17:19:49 -0700 (PDT)
Local: Tues, Jun 28 2011 8:19 pm
Subject: Re: ormsettings.eventHandler
I think I ran into this one as well. Try removing required="true" from
the tag-based version of preUpdate().

On Jun 28, 5:24 pm, Brian Kotek <brian...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »