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

Calling a method from a URL

From: ColdFusion Power Workshop

Video: Calling a method from a URL

I want to show you that ColdFusion does allow you the ability to call a ColdFusion component method, from outside your application or via the Internet and that's exactly what I'm going to do. So I'm using the bookingproperties.cfc and I'm going to call a method of this CFC, the one called list tours, from within the browser. So I won't be calling it from another ColdFusion page within my website. So I'll go out and do that.

Calling a method from a URL

I want to show you that ColdFusion does allow you the ability to call a ColdFusion component method, from outside your application or via the Internet and that's exactly what I'm going to do. So I'm using the bookingproperties.cfc and I'm going to call a method of this CFC, the one called list tours, from within the browser. So I won't be calling it from another ColdFusion page within my website. So I'll go out and do that.

What I need to do is plug in the URL in order to do that. And I have this somewhat setup in here so I'll go ahead and take advantage of that. And what I'm going to do is plug in local host, power workshop. That's my root folder. The booking folder, and the booking properties specifically. So you can see it's going right to this component.

And then, within the URL, I'm going to say method equals list tours. Now this method is the method right here that I'm going to be calling by hitting enter or return on my keyboard, and there is my method call. Now it does take a little bit of setup within your method in order to be able to do this. What I did, was I plugged this method output into a table just to make it look a little bit nicer for you when I went to run this tour. So let's go take a look at Booking Properties.

And take a look at that list tours that created this output. So, if I scroll down the page, list tours is down towards the bottom. And this is a new method that I added to the page. Notice that return type on this method is void. But I'm also setting it up access equals remote. Now if I try and call this method and it's not remote, let me put public in here, I'll save it and go back out and make a call once again.

And hopefully I have this in my history here and I do. You can see this component cannot be accessed remotely. I am trying to call it from outside my ColdFusion application, and it does not allow access of remote. So it does need to be access of remote, in order to be able to work with this. Now what I did was, I set a local variable, this is a new variable scope and it represents the scope for a function.

So, when I use local I can use this instead of saying var space. So, they're subtly different in terms of how they look and I think the local scope is much easier to work with. This is a new feature. So I'm setting that equal to all tours. What that's going to do is run the method, pull it into that variable, and then I'm going to output the content and notice I'm referencing it using that local variable.

And it's all just put in a table structure. The important piece is that you must have access of remote, in order to access it from a URL, but what you do is, call the component by its name and its path, put a question mark and then list the methods. If there were any arguments that needed to be passed into this method, I would simply put an ampersand, put the name of the argument, and an equals sign, equal to the value of that argument.

This one is a simplified example of working with that URL call to an instance method. But that is how you call the method of a component from a URL.

Show transcript

This video is part of

Image for ColdFusion Power Workshop
ColdFusion Power Workshop

39 video lessons · 1041 viewers

Candyce Mairs
Author

 
Expand all | Collapse all
  1. 1m 35s
    1. Welcome
      1m 35s
  2. 41m 29s
    1. ColdFusion installation
      9m 2s
    2. Installing ColdFusion Builder
      5m 41s
    3. Setting up the course files
      2m 0s
    4. ColdFusion Builder project setup
      7m 25s
    5. ColdFusion 10 Administrator enhancements
      6m 50s
    6. Setting up the database
      2m 30s
    7. Creating an Apache Derby data source
      4m 25s
    8. Customizing the ColdFusion Builder interface
      3m 36s
  3. 49m 50s
    1. What is the application framework?
      3m 20s
    2. CFC placement
      6m 47s
    3. Planning event code
      6m 28s
    4. Initializing application-level variables
      10m 14s
    5. Application methods
      6m 51s
    6. Triggering application methods
      8m 14s
    7. Request methods
      7m 56s
  4. 39m 45s
    1. Levels of error handling
      3m 50s
    2. Adding a site-wide error handler
      8m 22s
    3. Creating error templates
      8m 40s
    4. Using the error templates
      8m 31s
    5. Adding the onError method
      8m 15s
    6. Additional tips on error handling
      2m 7s
  5. 36m 6s
    1. What is a CFC?
      4m 50s
    2. Creating a static CFC
      8m 11s
    3. Calling a static CFC
      6m 47s
    4. Creating an instance-based CFC
      7m 16s
    5. Invoking an instance-based CFC
      9m 2s
  6. 28m 3s
    1. Reviewing the booking form
      7m 42s
    2. Working with the booking area component
      8m 33s
    3. Submitting the booking form
      7m 20s
    4. Controlling client-side form validation
      4m 28s
  7. 24m 10s
    1. Displaying the booking details
      8m 49s
    2. Inserting the booking form data
      7m 21s
    3. Creating an email confirmation
      8m 0s
  8. 29m 17s
    1. Using the cfproperty tag
      6m 20s
    2. Coding an instance-based component
      7m 23s
    3. Running the instance-based component
      7m 28s
    4. Calling a method from a URL
      4m 33s
    5. Calling a method from a form
      3m 33s

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 Power Workshop.

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.