calling one function inside another
Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:24 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Yes, you may call function of other cfc's. But, like working with class files in java or C++, if the file has no reference to instantiate that object (conferences) then it won't find the function. You will need to create an object instance [variables.conferences = createobject(component,conferences).init(dsn)] prior to calling any functions of the object [user.arrConferences = variables.conferences.GetConferences(userID)]. Cutter __ http://blog.cutterscrossing.com Crow T. Robot wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245561 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Also the cfinvoke tag will work if you like that better -- from within your addUser function: cfinvoke component=mycfcs.conferences method=GetConferences -- any arguments, use cfinvokeargument -- /cfinvoke -- Josh - Original Message - From: Cutter (CFRelated) [EMAIL PROTECTED] To: CF-Talk cf-talk@houseoffusion.com Sent: Thursday, July 06, 2006 10:47 AM Subject: Re: calling one function inside another Yes, you may call function of other cfc's. But, like working with class files in java or C++, if the file has no reference to instantiate that object (conferences) then it won't find the function. You will need to create an object instance [variables.conferences = createobject(component,conferences).init(dsn)] prior to calling any functions of the object [user.arrConferences = variables.conferences.GetConferences(userID)]. Cutter __ http://blog.cutterscrossing.com Crow T. Robot wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245567 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Actually, all the CFC's are loaded into the application scope, which is why the whole thing is confusing me. In application.cfm, here is one example of the code: !--- get conference CFC --- cfset application.conference = createObject(component,cfcs.conference).init(application.settings) Somaybe I'm missing a step in accessing it inside the users component? Matt Williams wrote: Unless the Conferences component is in the session or application scope, you'll need to create an instance of the conferences.cfc before you can call a method in it. cfset Conferences = createObject('component','conferences') / cfset myVar = GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245570 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Did you try this? cfset myVar = application.conference.GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Actually, all the CFC's are loaded into the application scope, which is why the whole thing is confusing me. In application.cfm, here is one example of the code: !--- get conference CFC --- cfset application.conference = createObject(component,cfcs.conference).init(application.settings) Somaybe I'm missing a step in accessing it inside the users component? Matt Williams wrote: Unless the Conferences component is in the session or application scope, you'll need to create an instance of the conferences.cfc before you can call a method in it. cfset Conferences = createObject('component','conferences') / cfset myVar = GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245578 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Yea, I was just about to write in that using it that way works. Thanks, everyone. Matt Williams wrote: Did you try this? cfset myVar = application.conference.GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Actually, all the CFC's are loaded into the application scope, which is why the whole thing is confusing me. In application.cfm, here is one example of the code: !--- get conference CFC --- cfset application.conference = createObject(component,cfcs.conference).init(application.settings) Somaybe I'm missing a step in accessing it inside the users component? Matt Williams wrote: Unless the Conferences component is in the session or application scope, you'll need to create an instance of the conferences.cfc before you can call a method in it. cfset Conferences = createObject('component','conferences') / cfset myVar = GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245584 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
Even though all the CFCs exist in the app scope, when you are _inside_ another CFC you shouldn't address the other CFCs that way. If you want an instance of Conference CFC, you shouldmake a new instance of it. This would be best inside the init() function so it's only made once. On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Actually, all the CFC's are loaded into the application scope, which is why the whole thing is confusing me. In application.cfm, here is one example of the code: !--- get conference CFC --- cfset application.conference = createObject(component,cfcs.conference).init(application.settings) Somaybe I'm missing a step in accessing it inside the users component? Matt Williams wrote: Unless the Conferences component is in the session or application scope, you'll need to create an instance of the conferences.cfc before you can call a method in it. cfset Conferences = createObject('component','conferences') / cfset myVar = GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245587 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: calling one function inside another
I agree 100% here. This kind of object composition save so many headaches and makes the main component stand alone as it should. On 7/7/06, Raymond Camden [EMAIL PROTECTED] wrote: Even though all the CFCs exist in the app scope, when you are _inside_ another CFC you shouldn't address the other CFCs that way. If you want an instance of Conference CFC, you shouldmake a new instance of it. This would be best inside the init() function so it's only made once. On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Actually, all the CFC's are loaded into the application scope, which is why the whole thing is confusing me. In application.cfm, here is one example of the code: !--- get conference CFC --- cfset application.conference = createObject(component,cfcs.conference).init(application.settings) Somaybe I'm missing a step in accessing it inside the users component? Matt Williams wrote: Unless the Conferences component is in the session or application scope, you'll need to create an instance of the conferences.cfc before you can call a method in it. cfset Conferences = createObject('component','conferences') / cfset myVar = GetConferences() / On 7/6/06, Crow T. Robot [EMAIL PROTECTED] wrote: Using Ray Camden's Galleon software, and I need to modify it a little. I've got a user.cfc file that takes care of all user functions. I have another, conferences.cfc, that takes care of all conferences. Now, after a user is inserted using the addUser method inside users.cfc, I have the need to call the GetConferences method that exists inside conferences.cfc inside the addUser function so that I can subscribe the user to all the conferences when they sign up. However, before I can get into that, I need to know why it seems like I am not able to call the GetConferences() function from with the users.cfc. I keep getting undefined errors unless I copy the GetConferences function into the users.cfc file. After that, it works fine. I'm quite new to the cfc thing, so any help in the underlying logic and the whys of the above behavior would be great. Thanks ~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:245637 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54