ColdFusion Has Many Roles to Play

Finishing up my series on my idea of why I am drawn to ColdFusion is my final point – ColdFusion has many roles to play. ColdFusion doesn’t force you to use only it for all layers of your web application. You can selectively choose to use ColdFusion for as much or as little of your application as you want. ColdFusion doesn’t just allow this, like everything else, it makes it easy. Off the top of my head here are some uses cases for ColdFusion in your application:

  • Traditional HTML generated application by ColdFusion
  • Complete client layer using built in ColdFusion AJAX components
  • Back end to AJAX driven front end using cfajaxproxy
  • Back end to Flex application using Flash Remoting or LiveCycle Data Services ES
  • Bridge between your application and messaging services (JMS, SMS, XMPP) with Event Gateways

Let’s start with the traditional HTML generated application:


SELECT *
FROM app.artists


Name City State
#firstName# #lastName# #city# #State#

Sure, I can just take a query and pass it to an HTML renderer and… instant data screen. ColdFusion can do the entire thing. But that code would provide a poor user experience. That table is pretty much just phoning it in. Instead, I can use ColdFusion’s built in AJAX features to make a better UI using a datagrid.

First I have to move the query to a CFC, and run it through a simple function that formats the data for the datagrid:



SELECT *
FROM app.artists








Once that is done, I can call that CFC from a datagrid component:









Or I can instead opt out of using ColdFusion UI components, and either roll my own or use an established framework (both using cfajaxproxy):

var cfData = new cfData();
cfData.setSyncMode();
cfData.setQueryFormat('column');

datatable = document.getElementById('dataTable');
res = cfData.list();
table = queryToTable(res);

datatable.appendChild(table);

function queryToTable(result){

table = document.createElement('table');
tbody = document.createElement('tbody');

for(i=0;i

If, however, I wanted to go with something other than HTML/JavaScript for the front end, I still have options. ColdFusion is perfectly suited to act as a back end for Flex. In fact that CFC above still works with Flex. To call it from Flex I just have to point an end point to it and add a datagrid:






But let’s say that you instead wanted to interact with some sort of other interface like SMS, JMS, or as in the following example, an XMPP client using Gtalk:











That’s a lot of mileage out of that little query. From that simple query, I’ve rendered a plain old HTML page, a ColdFusion AJAX display page, a custom written AJAX-driven page, a Flex display component, and a Gtalk Bot. That’s what I mean by ColdFusion can play lots of roles. It can do the whole thing, or just part of it. Combine that with the concepts in my previous post, and ColdFusion can do the following:

  • Act as a front end to business logic written in Java or .Net
  • Act as a back end to a front end written in Flex or HTML/Javascript
  • Act as a messenger from a back end written in Flex or Java to a front end written in Flex
  • Act as a messenger between all of these and a messaging service
  • And of course, it can be your front end, back end, and messenger all in one

The idea here is that when you use ColdFusion, you can either use it full hog, or selectively swap in technologies that better address your needs. ColdFusion doesn’t lock you in; quite the opposite, it opens doors for you.

One thought on “ColdFusion Has Many Roles to Play

  1. Very, very nice post, Terry. Not only a great apologetic for CF, but a succinct and compelling demo of functionality to help the converted appreciate the power at their fingertips. Thanks for doing it.

    Actually, this could make a nifty user group talk (just showing the examples, and expanding on things a little). If you may be interested, I’m always happy to have any CF speakers on my weekly Online ColdFusion Meetup (coldfusionmeetup.com), and now (in your new role) as much as before, you’d be most welcomed. If you may be interested, drop me a note: charlie at carehart dot org. If you can’t do it for some reason, flat out too busy for several weeks, let me know if you’d prefer to have me put one together. It really does deserve to be highlighted. I’d even propose doing it as an Adobe Dev Center article, and again if you can’t get the time to do it, I’d be willing to co-author something.

    Keep up the good work.

Leave a Reply

Your email address will not be published. Required fields are marked *