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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --