Tuesday, August 28th, 2007

Adobe ColdFusion 8 gets into the Ajax game

Category: Adobe, ColdFusion

<p>A lot of folks may not know this but Adobe ColdFusion’s recently released, version 8, has quite a bit of easy-to-use Ajax capabilities under the hood. By leveraging YUI, Ext and Spry and implementing certain functionality from these libraries in a nice wrapper, Adobe has made it fairly easy to build applications that can include sortable and dynamic grids, layout controls, and make use of Ajax with very little coding.

Take for example Raymond Camden’s recent post for creating a filtering and Google Suggest type of functionality:

You can enter a term and either click outside the box or hit the button. (Don’t hit Return/Enter.) While that works, an even slicker version is this:

<form>Search: <input type=”text” name=”search”></form>

<cfdiv bind=”url:results.cfm?search={search@keypress}”>

I’ve removed the button and notice now my bind is based on search@keypress. The @ symbol means I’m defining an event to listen to. Instead of onChange, I’ve used keypress (when using this format, drop the “on”). Now you get “filter as you type” search, all in 2 lines of code without a line of JavaScript. You can see this demo here:

http://www.coldfusionjedi.com/demos/ajaxsearch

While obviously a very simplistic demo, it is interesting that one line of could can do the data binding legwork and produce reasonable functionality.

Click here to see a demo in action.

Related Content:

Posted by Rey Bango at 6:00 am
9 Comments

+++--
3.4 rating from 41 votes

9 Comments »

Comments feed TrackBack URI

Glad to see CF showcased in these pages once in a while! ColdFusion is still suffering from the scorn it received around version 4.x, before it could handle XML or objects, causing many developers to discard it completely. It’s a real shame, because CF has addressed all those early issues and then some, and is now an extremely capable and scalable enterprise-class language.
I could take or leave the built-in AJAX support, though it is perfect for beginning developers because it does all the setup for them. What’s more important to me is the built-in interpreter for complex structures serialized as a JSON string.

Comment by Mike Ritchie — August 28, 2007

Agreed. I have played a bit with CF 8′s ajax toolkit and its quite impressive.

Comment by Jason Harris — August 28, 2007

>leveraging YUI, Ext and Spry and implementing certain functionality

So CF8 takes certain components from these frameworks, rather than loading the entire framework? Could the functionality be ported to Prototype and jQuery or are the components too tightly integrated with CF8? The PDF generation and rich Flash and PDF forms, and now AJAX makes CF more and more interesting to me. Would it be a reasonably easy switch from PHP + HTML + [JS Framework]? I do really love open-source though….

Comment by Charles — August 28, 2007

Hey Charles, I definitely think you should switch to CF, but I’m probably a bit biased. ;)

When using CF’s Ajax features, CF will load the ‘proper’ JS files for you. So if you do tabs, it loads what it needs. If you do tabs+windows+other stuff, it loads more. In other words, it loads only what it needs to.

Could you switch to Prototype? Not really. The UI components are mainly meant to be used as is. That doesn’t mean you can’t use prototype, but that you couldn’t use prototype’s tab control (if it has one) directly via CF’s tags.

That being said – nothing locks you into CF’s Ajax code. There are other very cool features that don’t tie you to a framework. cfajaxproxy is incredibly powerful. It creates a connection between JS and CFCs all in one tag. The Ajax debugger, while built with YUI, could obviously be used to debug anything.

I hope that gives you some idea.

As for trying to seriously answer your question on how easy it would be to switch – I would say CF is a fairly simple language to pick up. I know some folks would look down on it, but CF has already tried to be practical. I think some people have forgotten how nice ‘practical’ is. ;)

Comment by Raymond Camden — August 28, 2007

With so many different and equally powerful javascript frameworks, I’m surprised CF didn’t do something like Ext for the base Coldfusion.functions, rather than tie them to a particular library. It would be way more useful if the client-side scripts that are included in the /scripts section were to try and detect a library first, then wrap the ColdFusion.functions around the functionality of the particular libraries, and only include a base framework in the absence of one already existing. Either that or maybe CFDIV FRAMEWORK=”mootools”?

Comment by Mike Ritchie — August 28, 2007

…”scalable enterprise-class language”… Is not a phrase most people would use to describe Cold Fusion.

Comment by Chris — August 28, 2007

@Chris

ColdFusion has long been a ‘scalable enterprise-class’ language. The list of successful corporate clients is a long and distinguished one. For examples, check out the brief list at http://www.forta.com/cf/using/list.cfm?highlight=1 . That list includes such enterprise clients as AFLAC, BMW USA, E*Trade, Hasbro, and (importantly) Victoria’s Secret ;) . Perhaps the largest misunderstanding about ColdFusion’s popularity is that it has huge adoption among government and educational institutions running their internal sites. Because these mission critical applications are inward facing the general public isn’t aware of how widely distributed CF is.

One of the problems that CF has suffered is that a person will stumble on a poorly made site, see a *.cfm extention in the address bar, and assume that ColdFusion sucks. However, this is more a side effect of ColdFusion’s easy learning curve – because it is easy to get started creating applications people with little or no programming experience start putting out sites that suffer from lack of experience. Its important to separate what is poor implementation to actual detriments of the server product.

Comment by Matthew Reinbold — August 28, 2007

I’d be quite wary of using it within cf (though certainly not cf itself, which is great). The “simple” tabs example I saw loaded a massive 258kbs of yui/etc/cf/css includes!

It’s really only for someone who doesn’t know how to do these things much better directly.

Comment by ziggy — August 29, 2007

CF is very bloated and scalability is an issue.
It’s more like a tool for casual web developer and designer.
But for serious java/ajax developers, better go w/ a pure j2ee app server w/ the ajax framework of your choice. you have alot more control.
nothing against CF, but it’s definitely not “enterprise-class”.
- speaking from an 8-year certified cf developer…

Comment by Codelicious — October 10, 2007

Leave a comment

You must be logged in to post a comment.