Well here is the reason that i need to call the save after each object. I need to load the first object (object a) and then the other objects need to know about it, objecta.getId(). As far as the error collection goes that was my only option, try this for psuedo code.

initialize an error array

create first object
load first object's data
validate first object
add translated errors to array

create second object
load second object's data
validate second object
append errors to the array



On 8/2/06, Teddy Payne <[EMAIL PROTECTED]> wrote:
Well, the error collection when it returns the translated errors is already in array format. 

How about this for psuedo code:

create first object
load first object's data
validate first object
create new array to store collection

create second object
load second object's data
validate second object
append errors to the new array

if the array of errors has 0 errors
first object save
second object save

You really don't need the cftransaction as you have control over when you can use the save() function for each object.

Makes sense?

Teddy

On 8/2/06, Dan Vega < [EMAIL PROTECTED]> wrote:
Does anyone have ideas about this?

On 8/1/06, Dan Vega < [EMAIL PROTECTED]> wrote:
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --



--
Dan Vega
[EMAIL PROTECTED]
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --



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

Reply via email to