RE: CFC Lifecycle
Thanks all, this clears things up and re-enforces what I thought was correct. ;-) ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220893 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: CFC Lifecycle
Joe made a fine point. Just because you instantiate a CFC on a page that gets called does NOT mean it'll die after the page request is through IF you instantiate it into the SERVER, APPLICATION or SESSION scope. That said, I use this method, in my Application file, to instantiate commonly used CFCs. // intialize the query manager CFC APPLICATION.queryObj = CreateObject("component", "includes.queryManager"); And let's be honest here...if they weren't commonly used, we probably wouldnt' make them into a CFC now would we? -Original Message- From: Joe Rinehart [mailto:[EMAIL PROTECTED] Sent: Thursday, October 13, 2005 7:14 AM To: CF-Talk Subject: Re: CFC Lifecycle Hey Andy, > If I create an instance of a CFC on my page, carry out some processing > and then do cflocate to another page am I correct in assuming that > my CFC instance is now gone and if I wish to re-use it I must create > another instance of it? Exactly! A CFC instance is just a variable like any other - put it in the unnamed/variables scope and it only hangs out for the duration of the page. Put it in application/session, and it'll stick around. -Joe -- Get Glued! The Model-Glue ColdFusion Framework http://www.model-glue.com ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220885 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: CFC Lifecycle
Hey Andy, > If I create an instance of a CFC on my page, carry out some processing > and then do cflocate to another page am I correct in assuming that > my CFC instance is now gone and if I wish to re-use it I must create > another instance of it? Exactly! A CFC instance is just a variable like any other - put it in the unnamed/variables scope and it only hangs out for the duration of the page. Put it in application/session, and it'll stick around. -Joe -- Get Glued! The Model-Glue ColdFusion Framework http://www.model-glue.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220882 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: CFC Lifecycle
You've got it correct. An instance of a cfc created on a page is no different than any other variable created on a page - it's gone when you leave the page. Where it gets murky with CFC's is whether or not you're creating it with createObject or using cfinvoke to just hit a method that doesn't return an instance of the object. So, for instance this would work: #myObj.sayHello()# And, this would work: #hello##myObj.sayGoodbye()# without re-instantiating the object. The second does not keep a reference to the object for further use. On 10/13/05, Andy Mcshane <[EMAIL PROTECTED]> wrote: > > Just a quick question to help clear, hopefully, the last of the muddy > waters with regards to how CFC's work. > > A CFC that is initialized and stored within the application/session scope > is then available to use everywhere as required. > > Now I just want clarification on CFC's created at page level. If I create > an instance of a CFC on my page, carry out some processing and then do > cflocate to another page am I correct in assuming that my CFC instance is > now gone and if I wish to re-use it I must create another instance of it? I > am just a little confused on the whole lifecycle bit of CFC's, can anyone > provide some clarity? > > > ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220881 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: CFC Lifecycle
I am no pro with CFCs as I'm just learning them myself, but I believe the answer is yes, it will die after the page request is over. In the reading I've done, people will instantiate their CFCs into persistant variables such as server, session, or application scopes so that the instance of that CFC will be available to all page requests. So, let's say for example, I have some CFC that I invoke methods on quite often. Instead of invoking it repeatedly in various pages, I might as will just invoke it once and save that instance in the application scope so it is accessible to every page. You still have to be cautious of locking, just like any other variable, though. hth, Mike Andy Mcshane wrote: > Just a quick question to help clear, hopefully, the last of the muddy waters > with regards to how CFC's work. > > A CFC that is initialized and stored within the application/session scope is > then available to use everywhere as required. > > Now I just want clarification on CFC's created at page level. If I create an > instance of a CFC on my page, carry out some processing and then do cflocate > to another page am I correct in assuming that my CFC instance is now gone and > if I wish to re-use it I must create another instance of it? I am just a > little confused on the whole lifecycle bit of CFC's, can anyone provide some > clarity? > > ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220880 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
CFC Lifecycle
Just a quick question to help clear, hopefully, the last of the muddy waters with regards to how CFC's work. A CFC that is initialized and stored within the application/session scope is then available to use everywhere as required. Now I just want clarification on CFC's created at page level. If I create an instance of a CFC on my page, carry out some processing and then do cflocate to another page am I correct in assuming that my CFC instance is now gone and if I wish to re-use it I must create another instance of it? I am just a little confused on the whole lifecycle bit of CFC's, can anyone provide some clarity? ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220877 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