Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
It's common practice to store a copy of a CFC and a variable for use throughout your application. These singletons or single instances of objects are used a lot, but CFBuilder won't know about them unless you tell it where to find them. You can set up variable mappings to tell ColdFusion about any CFCs that you have stored in a scoped variable. To demonstrate this, let's assume that we already have access to our LoginService through an application variable, Application.LoginService. To tell CFBuilder that this CFC lives in a specific application variable, I just need to right-click on my project in the Navigator, choose Properties, and go to the ColdFusion Variable Mappings section.
Here, I can add as many mappings as I want. I will click New and I am going to map Application.LoginService to the cfcs.LoginService component. I need to use the exact same path here that I would use inside of my CreateObject statement. Click OK and I can see my new mapping. I can then add as many as I would like. If you make a mistake, you will need to actually delete the mapping and create a new one. There is no way to edit a mapping through this dialog. Click OK.
And now I am going to replace Line 8 with a new one. We will do Session.LoggedIn = Application. You can see Application selected in my code hints, so press Enter. I can then see LoginService in my code hints. Press Enter again, press a period. And because I am right up against the closing bracket on the cfset, my code hints don't pop-up. But if I press Ctrl+Spacebar, I can then see the AuthenticateUser method. Press Enter once more, and then I can add FORM.Username and FORM.password.
So, now I have access to all of the methods on this application scoped variable. Now, if you are using any sort of framework, like model-Glue, Fusebox or ColdBox, you will most definitely have a large number of objects that are inside of scoped variables. To get the most use out of these objects, be sure to set them up in the Variable Mappings in your project properties.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99263 Viewers
56 Video lessons · 112535 Viewers
71 Video lessons · 81341 Viewers
131 Video lessons · 39056 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.