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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290850
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4