Thanks for the reply Matt, I have to confess I'm not particularly looking forward to learning a framework. I was sort of hoping that defining class paths to cfcs would be a setting somewhere......
I ColdSpring sounds cool tho, I'll check it out. Thanks again Tim -----Original Message----- From: Matt Williams [mailto:[EMAIL PROTECTED] Sent: 11 October 2007 15:17 To: CF-Talk Subject: Re: OOP Coldfusion The quick way to fix this issue is to just set the argument type to "any". Coldfusion is dynamic and can handle that just fine. However, this can make debugging the app more difficult because instead of getting a helpful type-casting error, you may get something like tthe method cannot be found, further down the line of code execution. The slower way to fix this issue, and probably the better in the long run way, would be to learn and use ColdSpring to handle your object instantiation and dependencies. Using ColdSpring, you would declare the classes and their dependencies in an xml file and then do something like <cfset page = application.CSFactory.getBean('page') /> It will already have an instance of head in it because of the xml declarations. Matt On 10/11/07, Tim Ashworth <[EMAIL PROTECTED]> wrote: > Hi All, > > I'm working on an OOP project and am having a bit of a problem with > objects referencing each other. > > My folder structure is > > /siteRoot/ > > /siteRoot/core (Where all my classes are) > > /siteRoot/core/valueObjects > > I'm quite early on in the build so I'm just setting up my value classes. > > I've got two classes in there, one called Page, the other called Head. > > Back at the root I'm instantiating these classes in a cfm file called > testing. > > <cfset page = > CreateObject("component","core.valueObjects.Page").init()> > <cfset head = > CreateObject("component","core.valueObjects.Head").init(title:"This is > a new title")> > > So far so cool. The problem is that one of the properties of the Page > class is a Head object. > > This is populated with this function in the Page class > > <cffunction name="setHead" access="public" hint="Sets the Head > Object"> > > <cfargument name="head" type="core.valueObjects.Head" > required="yes"> > > <cfset variables.head = ARGUMENTS.head> > > </cffunction> > > However when I call the function from the testing page with : > > <cfset page.setHead(head)> > > I get an error : - > > The HEAD argument passed to the setHead function is not of type > core.valueObjects.Head. > > When as far as I'm concerned it is. The fix I came up with is to > change the argument in the setHead function to be only Head. Now this > sort of works as Page and Had live in the same folder, but I can see > problems further down the line unless I get this clear in my head. > > So am I a - doing this wrong, should there be a special "place" or > method of creating CF classes where they can reference each other with > complete class paths? > b - Just accept that the classes can only reference each > other relatively? > c - Go back to actionscript and stop pretending to be a > server side coder? > > Thanks in advance > > Tim ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290864 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

