Ok, now I have a grouping of objects in a transaction tag and if any objects validation fails the transaction tag will rollback. My question is now how can I group these objects together for validation. Lets look at the following example. In theory this is what you would want to do. The problem with the statment below is that if object b has any errors it overwrites the first errorCollection.
<cftransaction action="" clear="all">
...some stuff happens here
<!--- validate user record --->
<cfset userRecord.validate() />
<cfset errorCollection = userRecord._getErrorCollection() />
<cfset userRecord.save(false)>
...some stuff happens here
<!--- validate object b --->
<cfset objectbRecord.validate() />
<cfset errorCollection = object b._getErrorCollection() />
<cfset object bRecord.save(false)>
<cfif NOT ErrorCollection.hasErrors()>
<!--- we must be ok if we made it this far --->
<cftransaction action=""
<cflocation URL="" addtoken="false"/>
<cfelse>
<cftransaction action=""> </cfif>
</cftransaction>
My next problem is that I can not simply create my own and add to it because everytime you create a reactor.util.ErrorCollection object you must pass it a dictionary file, so the following would not work either
<cftransaction action="" clear="all">
<cfset errorCollection = createObject("component","reactor.util.ErrorCollection")>
<cfset errorCollection.init
()>
...some stuff happens here
<!--- validate user record --->
<cfset userRecord.validate() />
<cfset errorCollection = userRecord._getErrorCollection() />
<cfset userRecord.save(false)>
...some stuff happens here
<!--- validate object b --->
<cfset objectbRecord.validate() />
<cfset errorCollection = object b._getErrorCollection() />
<cfset object bRecord.save(false)>
<cfif NOT ErrorCollection.hasErrors()>
<!--- we must be ok if we made it this far --->
<cftransaction action=""
<cflocation URL="" addtoken="false"/>
<cfelse>
<cftransaction action="">
</cfif>
</cftransaction>
Is there any way of doing what I am trying to do? The only Idea i had is create a seperate errorObect for each object and then just use the getTranslatedErrors() to add the translated errors from the dictionary files to an array that initialize at the begging of my transaction. Any help would be appreciated, and I apologize for all the questions, im still getting used to reactor.
--
Dan Vega
[EMAIL PROTECTED]
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- [Reactor for CF] adding to the error collection Dan Vega
