As a heavy user of Rob Gonda’s ajaxCFC library, I’ve incorporated it into almost every app I’ve written in the past two years. The only restriction that required me to write workarounds was the fact that you could only invoke ColdFusion Components directly. The thing is, I also love ColdSpring to manage dependencies and to implement my Aspect Oriented Programming components.
What I want is to be able to call my ColdSpring beans with ajaxCFC so that I can make my asynchronous calls, get serialized data back, and all the while utilizing the dependencies set up in my beans. Well, I finally got around to modifying Rob’s code to allow for this. I use the jQuery branch, so my solution currently only works for that implementation. I may try to work on the DWR version, but that’s unlikely because I don’t use it.
There are three changes to how you invoke ajaxCFC in order to work with ColdSpring beans.
The URL Attribute
Instead of the URL value being the path to your logic component, its value should be the path to the ajax.cfc component
url:'com/company/common/ajax/ajax.cfc'
The Bean Attribute
This property’s value will be the name of the ColdSpring bean you want to use.
bean: 'Facility'
The Factory Attribute
This property’s value will be the name of your ColdSpring bean factory.
factory:'application.beanFactory'
A Complete Invocation
Here’s a sample call stripped directly from one of my applications
$.AjaxCFC({
url:'com/company/common/ajax/ajax.cfc',
bean: 'Facility',
factory:'application.beanFactory',
method: 'getFacilities',
data: { 'orderby':orderByField },
useDefaultErrorHandler: false,
success: function(results) {
$("#facilitySelectContainer").html(results);
},
error: function(results) {
Ext.MessageBox.alert('Error Notification', 'There was an error while loading the facilities. Please try again.')
}
});
The Code
There are two files you need to replace.
- ajax.cfc
- jquery.AjaxCFC.js

