Proper way to remotely call a CFC in CB4?

I’m starting to build a calendar/schedule system and (at the moment) I’m using fullcalendar.js (www.fullcalendar.io). Following the example blog by Ray Camden (http://www.raymondcamden.com/2011/06/17/FullCalendar-jQuery-Plugin), I’m trying to call a cfc to pull a list of events.

The issue I’m having is pretty simple… 404. Here’s my code:

$(’#calendar’).fullCalendar({

aspectRatio: 2,

events:’/handlers/instructor.cfc?method=getSchedule’,

dayClick: function() {

alert(‘a day has been clicked!’);

}

})

I’ve tried /handlers/, I’ve tried /models/ but neither works. The path is valid from the webroot. Is Coldbox intercepting it? When I used MuraCMS, I had to have a /remote/ folder to put such files in, otherwise Mura blocked it. I don’t recall having this problem back in Coldbox 3.

Thanks!

Rob

The default Application.cfc only runs Coldbox requests for requests to “index.cfm”

That said, if you’re wanting to directly invoke a method from the URL, make sure you extend the ColdboxProxy base class and make your method access=“remote”. You should be able to hit the same URL in your browser and confirm what’s happening.

It doesn’t matter where your remote proxies are, but most people put them in a /proxy or /remote folder. Note, if you do this, make sure you’ve set the coldbox root path variable in your application.cfc so the framework can boot up correctly if the first request is to a proxy.

http://coldbox.ortusbooks.com/content/proxy/index.html

I’ll also add that many people don’t use the little ‘trick’ of hitting CFC methods directly. instead, they just hit the route to a regular handler and use event.renderData() to return JSON, or whatever else the Ajax call is expecting to get back. This has several advantages. One is that proxies run “outside” the framework so they have some extra hops they must jump through. Seconly, proxies don’t get the normal request lifecycle so you can’t secure them with things like the preProcess interception point. Using a REST API built with good old ColdBox handlers doesn’t have any of those problems. Ray never got into frameworks, so I’m not surprised he just demoed the old school method of calling a remote CFC method.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

That’s what i’m trying to do – call the handler and return it via event.renderdData; that’s how I had always done it.

What do I need to do to do it that way? That’s why I was attempting to call /handlers/instructor.cfc (the actual handler).

Rob