Thanks João
I dug into the generated code and I could not find anything that
really resembled what you posted, but I did find something that may be
a similar error.
The ContractRecord.getAgency() method has this line:
<cfset variables.children.Agency.load('AgencyUUID,') />
To me that looks highly suspect - I can't see how that would ever
return anything but a blank record.
This is running version 330 (updated from SVN today).
Cheers
Mark
On 7/25/06, João Fernandes <[EMAIL PROTECTED]> wrote:
Mark,
I think that I found the problem. I looked inside my generated files and
when I have a hasOne relationship like yours I would have this for the
"<cfset objContractRecord.setAgencyUUID(arguments.agencyUUID)>"
<cffunction name="setAgencyUUID" hint="I set the AgencyUUID value and reset
related objects." access="public" output="false" returntype="void">
<cfargument name="AgencyUUID" hint="I am this record's AgencyUUID
value." required="yes" type="string" />
<!--- if the value passed in is different that the current value,
reset the valeus in this record --->
<cfif arguments.country_code IS NOT getcountry_code()>
<cfif StructKeyExists(variables.children, "Agency") AND
IsObject(variables.children.agency)>
<cfset
variables.children.agency.resetParent() />
</cfif>
<cfset variables.children.agency = 0 />
<cfset _getTo().AgencyUUID = arguments.AgencyUUID />
<!--- load the correct address record --->
<cfset getAgencyUUID() />
</cfif>
</cffunction>
I think that the last <cfset getAgencyUUID()> should be instead <cfset
getAgency()> so it should load the correct record.
We'll wait for Doug's opinion about this.
João Fernandes
Dep. Informática - Área de Desenvolvimento
Cofina media
Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL
Tel (+351) 213 185 200 . Fax (+351) 213 540 370
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Mark Stanton
Sent: terça-feira, 25 de Julho de 2006 13:54
To: [email protected]
Subject: Re: [Reactor for CF] abstractRecord.hasErrors() mayhem
Thanks Teddy
I understand that relationship but I'm still not sure about the
validation behaviour. Why is one object causing the implicity
validation of the other? It's not even loading the related object
before validating it.
Mark
On 7/25/06, Teddy Payne <[EMAIL PROTECTED]> wrote:
> Well, all of your questions stem from your Reactor.xml declaration.
>
> Based upon your reactor.xml, when you execute
>
>
> <cfset objContractRecord =
> variables.objReactor.createRecord('Contract')>
>
> Now because of your linking rector.xml you can now have:
>
> <cfset qryAgency =
> objContractRecord.getContractIterator().getQuery() />
>
> or
>
> <cfset arAgency =
> objContractRecord.getContractIterator().getArray() />
>
> This allows you to show all the associated Agencies for a Contract in a
nice
> neat array or query.
>
> Teddy
>
>
>
> On 7/25/06, Mark Stanton <[EMAIL PROTECTED]> wrote:
> > Hey All
> >
> > I've got a curly one....
> >
> > My reactor.xml has:
> >
> > <object name="Agency">
> > <hasMany name="Contract">
> > <relate from="AgencyUUID" to="AgencyUUID"/>
> > </hasMany>
> > </object>
> > <object name="Contract">
> > <hasOne name="Agency">
> > <relate from="AgencyUUID" to="AgencyUUID"/>
> > </hasOne>
> > </object>
> >
> > I have some code that creates a new contract...
> >
> > <cfset objContractRecord =
> variables.objReactor.createRecord('Contract')>
> >
> > <cfset objContractRecord.setContractUUID
(createUUID())>
> > <cfset objContractRecord.setAgencyUUID(arguments.agencyUUID)>
> > <cfset objContractRecord.setStartDate(arguments.startDate)>
> > <cfset objContractRecord.setEndDate(arguments.endDate)>
> > <cfset objContractRecord.setValue(arguments.value)>
> > <cfset
> objContractRecord.setDescription(arguments.description)>
> >
> > <cfset objContractRecord.validate()>
> >
> > <cfif NOT objContractRecord.hasErrors ()>
> > <cfset objContractRecord.save()>
> > </cfif>
> >
> > ...but hasErrors() is returning true.
> >
> > ...but
>
objContractRecord._getErrorCollection()_getErrorsTranslated()
> > is returning an empty array.
> >
> > So where is my error?
> >
> > I ended up digging into the hasErrors() method of the abstractRecord
> > object and found that it checks children as well as the current object
> > (not sure I like that idea, but anyway).
> >
> > So I create a getChildren() method in my ContractRecord and run the
> following:
> >
> > <cfset children = objContractRecord.getChildren()>
> > <cfloop collection="#children#" item="child">
> > <cfdump
var="#children[child].validated()#"><br>
> > <cfdump
var="#children[child].hasErrors()#"><br>
> > <cfdump
>
var="#children[child]._getErrorCollection().getTranslatedErrors()#"><br>
> > <cfdump var="#children[child]._getTO()#"><br>
> > </cfloop>
> >
> > From this I can tell:
> > * I have one child, an AgencyRecord object
> > * children[child].validated() is true
> > * children[child].hasErrors() is true
> > *
>
children[child]._getErrorCollection().getTranslatedErrors()
> returns
> > a number of errors
> > * children[child]._getTO() returns an EMPTY AgencyTO
> >
> > I scratch my head, go have some lunch and when I get back I add one
> > line to my code:
> >
> > <cfset objContractRecord.getAgency()>
> >
> > ..just before the <cfset objContractRecord.validate()>
> >
> > Now everything works - no validation errors.
> >
> > All of this has me stumped for a number of reasons:
> >
> > - Why is an child AgencyRecord getting checked when I validate a
> ContractRecord?
> > - When it fails why does it fail silently? Could it not report the
> > problem to the ContractRecords ErrorCollection?
> > - Why is my AgencyRecord reporting that it has been validated? I
> > certainly didn't run validate() on it (I didn't even know it was
> > there). Maybe _setErrorCollection() is being called on it somewhere
> > during instantiation?
> >
> > Anyway sorry for the rant and thanks in advance for any advice.
> >
> > --
> > Mark Stanton
> > Gruden Pty Ltd
> > http://www.gruden.com
> >
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
> -- --
> > Reactor for ColdFusion Mailing List
> > [email protected]
> > Archives at:
> http://www.mail-archive.com/reactor%40doughughes.net/
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
> -- --
> >
> >
>
>
>
> --
> <cf_payne />
> http://cfpayne.wordpress.com/
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
> Reactor for ColdFusion Mailing List
> [email protected]
> Archives at:
> http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- --
--
Mark Stanton
Gruden Pty Ltd
http://www.gruden.com
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
--
Mark Stanton
Gruden Pty Ltd
http://www.gruden.com
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --