Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you are like most developers, you've hard coded a URL reset value in your Application.cfc to restart your application when you need to reinitialize everything. This is generally done by calling the onApplicationStart method from your onRequestStart method in Application.cfc. Adobe has added a new function in ColdFusion 9 that will essentially do the same thing. Restarting your application on demand from any page or code in your application. So to show how this works, we are going to open ApplicationStop.cfm in Chapter 2 and all I'm doing here is dumping my application scope, and here I have what is essentially the URL reset that most people put inside their Application.cfc.
So if we have reinit in the URL, I am going to run ApplicationStop and then redirect back to ApplicationStop.cfm. So let's see how this works. I am going to switch to the browser, and just load up my ApplicationStop page. So we'll go to Chapter2/ApplicationStop.cfm. Now here we see our application name and we see that the application was started on the 15th at 4:29 p.m. If I refresh this page, that values is going to stay the same every single time.
Now if I go up here to the URL, I'll put ?reinit and run it. It's going to run ApplicationStop and then redirect me back to the same page. Now what we are going to notice is that the started time changes. Now we can see that the application. started equals the 15th at 5:01 p.m. So basically what's happened is the application has entirely stopped and on ApplicationStart as run on my next page request. What also happens when you run ApplicationStop is the entire ORM configuration is reloaded as well.
Now we are going to learn about that in another section, when I talk about ORM and hibernate. The usefulness of this feature could be debated, but I think it gives a nice clean way to reset an application without directly accessing methods in the Applications.cfc. There is now no need to call onApplicationStart. So the onApplicationStart may or may not be always available to you when you need them. If you wanted to restart the application from deep inside a component, you would normally have to do a redirect, which passes your fancy URL up to the query string to restart the app.
Now you can just call ApplicationStop and the next page request will restart everything from the beginning.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 96615 Viewers
56 Video lessons · 110335 Viewers
71 Video lessons · 79163 Viewers
131 Video lessons · 37953 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.