Best of ColdFusion 10: CFShoutout

This post is more than 2 years old.

Our third entry in the Best of ColdFusion 10 contest comes from Ben Dalton. It mixes quite a few ColdFusion features including REST, Web Sockets, and ORM/Solr. On top of that, it is also one of the first uses I've seen of ESRI's mapping service. Most people use Google Maps but it certainly isn't the only option. Ben also mixed in HTML5 geolocation for good measure.

Because this application could be used for evil spammy/troll purposes, I will not be hosting a live version. Instead, I'll simply show some screenshots and at the end tell you how to grab the code yourself.

The application allows folks to send messages (shout outs) to other users. Because geolocation is used we know where you are when you make the shout out. When you first hit the application, any previous shout outs are loaded and displayed on the map.

Clicking the shout icon lets you create a new message:

Any connected users automatically see the new shoutout due to the use of websockets.

Let's look at some of the code. First - check out the ORM CFC used for shoutouts. I absolutely love how easy it is to enable Solr-based indexing:

Basically one attribute in the component tag turns it on (and adds autoindexing, which you could do in Application.cfc at a global level) and another argument to the content property tells Solr which data to actually index. I don't think he is actually using a search yet in the application (in my copy he just gets them all), but his REST service supports a find operation so it is ready to be used.

Another interesting issue is the need to set up REST support for an application. I like how he used a simple URL hook to automate this - as well as handling ORM indexing. You can trigger both in one request. But the important one is the REST call. It must be done before you use any REST based application in ColdFusion 10. This isn't a big deal I guess - you just don't want to forget it. Here is Ben's Application.cfc:

Want to see more? Ben set up a screencast here and you can download the bits at - of course - Github:

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Sameer posted on 6/20/2012 at 10:39 PM

Wow! That's a super cool app!

Comment 2 by Ben Dalton posted on 6/21/2012 at 12:53 AM

This was a fun project. I enjoyed playing with websockets for pushing real-time data updates to the client from the server. Client-Client communication is interesting and has quite a few use cases, Server-client data "pushing" has a TON of interesting uses.

It would actually be very easy to adjust an existing CF application to broadcast a notification when data has been updated and trigger a refresh event in an "AJAX" front end. This would prevent polling and allow people to have always-up-to-date data sets in a rich-client situation.

Comment 3 by PaulH posted on 6/21/2012 at 3:45 AM

very slick.