Ahh learnt something new there.  Also looks like that fires the
before/afterValidate methods on the record, but creating the validator
manually and passing the record in will not.
 
Should the RecordValidator object not be the one to call the
before/afterValidate methods on the record, not the record itself?
So the validate method of my ProductValidator would look something like 
 
 <cffunction name="validate" .. >
  <cfargument name="ProductRecord" ... />
  <cfargument name="ErrorCollection" ... />
 
    <cfset arguments.Productrecord.beforeValidate()>
  
   <cfset validateProductId(arguments.ProductRecord,
arguments.ErrorCollection) />
    ....

    <cfset arguments.Productrecord.afterValidate()>
  
  <cfreturn arguments.ErrorCollection />
 </cffunction>
 
And abstractRecord.validate() could then just be
 
 <cffunction name="validate" access="public" hint="I validate this
object." output="false" returntype="void">
  <cfset
_setErrorCollection(_getReactorFactory().createValidator(_getAlias()).va
lidate(this)) />
 </cffunction>
 
Just a thought..
Chris
 


________________________________

        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Brian Kotek
        Sent: 20 July 2007 16:33
        To: [email protected]
        Subject: Re: [Reactor for CF] Reactor and Triggers


        Actually just FYI, you don't have to manually created the
validator, you can do this through the Record:


        <cfset product =
reactor.createRecord("Product").load(ProductId=1)>
        <cfset product.setName("Foo")>
        .....
        <cfset product.validate()>
        <cfif product.hasErrors()>

        <cfdump
var="#product._getErrorCollection().getTranslatedErrors()#">
        </cfif>




        On 7/20/07, Chris Blackwell < [EMAIL PROTECTED]>
wrote: 

                Roland,
                 
                Yeah, the docs still need some work :)
                 
                Take a look in reactor/base/AbstractRecord.cfc You'll
see methods for before/afterValidate, Load, Delete and Save. 
                You can override these methods in your generated Record
objects to implement anything you need, just remember to call the super
method
                 
                Validation is pretty simple, create your record, create
a validator, pass the record to the validator which returns an error
collection.
                 
                <cfset product =
reactor.createRecord("Product").load(ProductId=1)>
                <cfset product.setName("Foo")>
                .....
                <cfset productValidator =
reactor.createValidator("Product")>
                <cfset errorCollection =
productValidator.validate(product)>
                 
                <cfdump var="#errorCollection.getAsStruct()#">
                 
                Cheers, Chris
                 


________________________________

                        From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Roland Mai
                        Sent: 20 July 2007 14:23
                        To: [email protected]
                        Subject: [Reactor for CF] Reactor and Triggers



                        Hi,

                        I come from a Rails background and I like having
triggers for a record such as before_save, before_update, before_create,
after_*.

                        I am wondering if reactor does this. Also I
still need to figure out how reactor does validation. 

                        I looked at the docs on
livedocs.reactorframework.com but they really need work.

                        If you guys have any good sources for
documentation or at least samples where validation is done and triggers
are added to a record, please do share. 

                        Thanks,

                        Roland

                        -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --
                        Reactor for ColdFusion Mailing List
                        [EMAIL PROTECTED]
                        Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
                        -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --


                -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
                Reactor for ColdFusion Mailing List
                [EMAIL PROTECTED]
                Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/ 
                -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- 



        -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- --
        Reactor for ColdFusion Mailing List
        [EMAIL PROTECTED]
        Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
        -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- --



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to