Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Working with components

From: ColdFusion Builder Essential Training

Video: Working with components

ColdFusion components or CFCs have become the de facto standard in new ColdFusion applications over the last few years. In order to make developing with CFCs as efficient as possible, CF Builder gives you a lot of help when working with your components. So, let's take a look at exactly how much work CF Builder is going to save us. Returning to the login.cfm page we were working on in the last video, I am going to take my authentication logic here, which is basically just a query and a check against the recordcount, and move that into a login service component.

Working with components

ColdFusion components or CFCs have become the de facto standard in new ColdFusion applications over the last few years. In order to make developing with CFCs as efficient as possible, CF Builder gives you a lot of help when working with your components. So, let's take a look at exactly how much work CF Builder is going to save us. Returning to the login.cfm page we were working on in the last video, I am going to take my authentication logic here, which is basically just a query and a check against the recordcount, and move that into a login service component.

I am going to place my component inside of the cfcs directory. So, I am going to right-click on cfcs, choose New, and ColdFusion Component. And now the New ColdFusion Component wizard is going to write most of the CFC structure for me. The first section of the wizard just determines where the CFC is going to be placed. In this case, it's in the same directory I right-clicked on to create the CFC. If I wanted to move it, I can just click Browse and then I can specify the component name, which is going to be the name of the file minus the .cfc, so we will call this LoginService.

I can then specify all of the attributes for the CF component tag. I will provide a hint. Provides Login Services for my application. I can give it a display name. I can specify if this is going to extend another CFC, and if I click browse here, I can actually see every CFC the CF Builder is aware of. You can see all of my ART, ARTDAO, ARTGateway, and ARTService inside of the cfcs directory. I can also see all of the cfdocs and CFIDE CFCs.

For example, here are all the adminapi components. For now, we will click Cancel. I can also specify if this CFC implements any interfaces. This particular component won't be outputting any content, so I will choose false for Output. And then I can choose whether or not I want this to be a ColdFusion 9 script style CFC. For now, I am going to stick with the regular tags. Click Next, and I can now specify all the properties and functions for my component. On the Properties, just click Add, and I can specify all of the attributes for CF property tag.

Down here at the bottom, I can also have CF Builder add getters and add setters for each of the individual properties. I can specify the access for each of those getters and setters. And if I am building a large value object CFC with say a dozen CF property tags, this will save me tons of time typing out redundant getters and setters. Our LoginService won't have any properties, so we will just click Cancel. We will have one function though. Click Add Function and our function is going to be called AuthenticateUser.

I don't need any of these three attributes. I will specify the access type, which is going to be public. Our return type is going to be Boolean. I can either type in a return type. For example, if I was going to return another component, I could put in the path to that component, or if I press the down arrow on my keyboard, I can choose one of the built-in return types. And for the output, we will choose false. And we don't need return format, SecureJSON, or VerifyClient, since we are not working on remote function calls. Click OK.

And I can see my function is added to the Functions list. Now I just need to add my two arguments to this function. Click Add Argument. The first argument is our username. We don't need the DisplayName or the Hint, but I will specify the type as being a string. This is going to be required and will not have a default value. Click OK. Then we will add our next argument, which will be password. It's the same thing. It will be a string, and required, with no default value. Click OK.

Then I can see both of my arguments as a comma-separated list, next to the function name. Now that that's complete, I will click Finish. The CF Builder opens out my LoginService and I now have my function ready to accept all of my business logic. So, let's drop that business logic in here real quick. I will go back over to login.cfm and I will cut my query, and go over to the LoginService and we will add it here inside the function. We will var our variable first. Paste the query. I am going to double-click on the LoginService page, so we can see the entire thing.

I will replace FORM with Arguments, and then return whether or not the user successfully validated. So, rsValidation.recordcount is greater than zero. So, I will save this file, and we will go back over to the login.cfm and actually use our new object. So, on login.cfm, I will delete my blank lines here and we will remove this.

Now I need to insert the call to my authenticate user method. I am going to do that by using the Services Browser, which should be, by default, down here in this bottom group of views. If it's not showing, just go to the Show View menu, under Window. If I expand my server here, it will show me all of the CFCs that are available on this server. So, I will expand the cfcs directory. I can see my LoginService. And I can just right-click and choose Insert CreateObject.

And it will add the CreateObject call exactly where my cursor was. I will back up, get rid of the line break, press the period, and now I can see the methods that are available on that object. CFBuilder will go through and introspect all of your components and show you all of the available methods. So, I can press Enter, and then pass in FORM.Username and FORM.Password. I can do a little bit more with the Services Browser though. Let's go to a new line. And instead of using a CreateObject call, I can use the CFInvoke.

And I can actually do that on the method. Choose my method. Choose Insert CFInvoke. It will add the CFInvoke. It's calling the proper component, my method. It's setting my returnVariable, which in this case I actually want to be Session.LoggedIn. And then it provides a cfinvokeargument for each of the arguments on that method. If I scroll down here a bit more on my Services Browser, I can then take a look at each of those arguments. The last trick I use all the time for navigating around my components is inside of the code editor, if I press and hold the Command key or the Ctrl key on Windows, I can hold my mouse over an object or a method and click on it, and it will take me directly to that object or method.

So, as you can see, I clicked on AuthenticateUser. It brought me right to the authenticate method inside of the LoginService component. If I go back over here to login.cfm, I can do the same thing with the CFC itself, press Command, click on LoginService, and it will take me to the first line of the LoginService component. CFBuilder has some great component integration, just don't forget to use it. Instead of choosing New in ColdFusion page, choose New ColdFusion Component and fill out the wizard. Keep your Services Browser open and handy and don't forget to hold down the Command or the Ctrl key to quickly navigate in between your ColdFusion pages and their matching components.

Show transcript

This video is part of

Image for ColdFusion Builder Essential Training
ColdFusion Builder Essential Training

40 video lessons · 3866 viewers

Daniel Short
Author

 
Expand all | Collapse all
  1. 7m 48s
    1. Welcome
      59s
    2. Installing ColdFusion Builder
      2m 20s
    3. Installing ColdFusion Builder as a plug-in
      3m 18s
    4. Using the exercise files
      1m 11s
  2. 17m 42s
    1. Workspace overview
      2m 25s
    2. Organizing your workspace
      6m 19s
    3. Adding and selecting workspaces
      2m 53s
    4. Installing and managing plug-ins
      6m 5s
  3. 12m 12s
    1. Creating projects
      2m 11s
    2. Importing projects
      2m 48s
    3. Creating project working sets
      2m 23s
    4. Managing projects
      2m 22s
    5. Linking folders
      2m 28s
  4. 23m 2s
    1. Configuring and managing ColdFusion servers
      6m 26s
    2. Using the Services Browser
      4m 15s
    3. Using RDS Dataview and Fileview
      4m 52s
    4. Using FTP
      7m 29s
  5. 18m 10s
    1. Creating editor profiles
      2m 6s
    2. Using Code Assist
      5m 43s
    3. Setting code coloring
      4m 5s
    4. Using shortcut keys
      3m 5s
    5. Working with outlines and syntax checking
      3m 11s
  6. 37m 40s
    1. Using code completion
      7m 25s
    2. Using snippets
      9m 23s
    3. Using SQL editing and the Query Viewer
      5m 55s
    4. Working with components
      7m 27s
    5. Working with variable mapping
      2m 14s
    6. Navigating code and documents
      5m 16s
  7. 13m 12s
    1. Getting set up
      3m 50s
    2. Using the ColdFusion debugger
      5m 37s
    3. Watching logs with Tailview
      3m 45s
  8. 13m 8s
    1. Installing extensions
      4m 5s
    2. Using the CFC Generator extension for ColdFusion 8
      4m 52s
    3. Using the CFC Generator extension for ColdFusion ORM
      4m 11s
  9. 34m 5s
    1. Building a simple contact form extension
      3m 42s
    2. Creating user interfaces
      8m 55s
    3. Packaging the extension
      3m 55s
    4. Building the handler
      8m 10s
    5. Using the Builder extension
      9m 23s
  10. 25s
    1. Goodbye
      25s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed ColdFusion Builder Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.