ColdFusion Query Json Custom Data Reader For ExtJS

Adobe's implementation of JSON return for ColdFusion is great, and frustrating. They use a non-standard return in that, instead of the expected name/value pairs, they return first a COLUMNS element, listing the column names only once, and then the DATA array of the record set values. The column names are listed in the order with which the data is listed in each array element. This is great, in the fact that the data packets are much smaller than the traditional return (traditional meaning, that which is returned by most other app servers), but the down side is, it isn't traditional.

John Wilson wrote a custom Data Reader for the Ext JS library, to help with parsing the ColdFusion return. However, although it created records within a Data Store, it didn't handle the column aliasing you are usually capable of when defining fields, nor did it properly cast variables as it should. I finally had a chance to run it through Firebug, and step through the process, at which point I also really had a chance to review the custom extension.

While it worked, it really wasn't using the best tool for the job. The extension extended the base component. The ColdFusion return basically gives you an Array of records (the DATA), and Ext JS already provides an object that extends the JsonReader. So, after some refactoring and general tinkering, I now release the CFQueryReader custom Ext data reader.

Inspired by the CFJsonReader, originally writtin by John Wilson (Daemach).

This Custom Data Reader will take the JSON return of a ColdFusion Query object, rather returned straight up, or via the ColdFusion QueryForGrid() method.

The CFQueryReader constructor takes two arguments @meta : object containing single key/value pair for the 'id' of each record, equating to the 'mapping' of the column @recordType : field mapping object

The recordType object allows you to alias the returned ColdFusion column name (which is always passed in upper case) to any 'name' you wish, as well as assign a data type, which your ExtJS app will attempt to cast whenever the value is referenced.

ColdFusion's JSON return, for a ColdFusion Query object, will appear in the following format:

view plain print about
2"STREXPENSECATEGORIES"],"DATA" :[[2,"Carpet Cleaning",1,"Cleaining"],
3[1,"Cleaning Service",1,"Cleaining"]]}

The ColdFusion JSON return on any query that is first passed through ColdFusion's QueryForGrid() method will return the object in the following format:

view plain print about

The is designed to accomodate either format automatically. You would create your reader instance in much the same way as the CFJsonReader was created:

view plain print about
1var myDataModel = [
2    {name: 'myIdField', mapping: 'MYIDFIELD'},
3    {name: 'data1', mapping: 'DATA1'},
4    {name: 'data2', mapping: 'DATA2'}
7var myCFReader = new{id:'MYIDFIELD'},myDataModel);

Notice that the 'id' value mirrors the alias 'name' of the record's field.

The CFQueryReader is available from the below download link. Anyone having any issues just post a comment. You may also find information on the Ext JS Forum Post.

Hurdles For ColdFusion Hosting Providers

One thing that we, the ColdFusion community, have been hearing since the release of ColdFusion 8 is that hosting costs should come down. Adobe has been working hard to strike deals with hosting providers to provide hosting solutions that are as competitive as hosting for other server-side languages, such as .NET or PHP. They've been doing this by doing things like changing their EULA agreement to support multi-procs, disaster recovery backups, and VM hosting, as well as through special licensing deals. Unfortunately, outside forces are working against them in this.

>Hosting services contain a lot of other costs, that are generally hidden to the end user. One such cost is in server administration. Any developer, setting up their own development environment, will realize that the real manual labor is spent in IIS or Apache administration, DNS management, SQL configuration and the like. Most hosting companies utilize third party software to help automate a lot of these tasks, cutting maintenance time significantly. There haven't been many software control panels that support ColdFusion. Chief among these, for some time, has been Parallels Plesk Control Panel. This software is brought to you by the same folks who bring the popular VM used on Macs to virtualize Windows. It's an extremely nice piece of software, allowing a very nice interface that integrates with several key technologies used by most any hosting provider.

So you might be asking "What's the problem?" Well, the suits at Parallels have moved to a Software As A Service model, and the pricing structure has changed significantly. There were other options out there, like Ensim Pro, Helm, and H-Sphere, but Parallels bought them all up, effectively taking over the market for hosting Control Panels that support ColdFusion. Nice monopoly they have now, at least within our space.

Outside of the community banding together to write their own software, their aren't any other options currently available for a ColdFusion hosting Control Panel. There is a very nice package for Windows based systems called dotnetpanel, but they do not currently support ColdFusion. They are considering support, pending justification to build it. My friend Emmet McGovern, of Full City Media (the kind folks who host this blog, and who always have my thanks), is on a mission to give dotnetpanel that justification. He started a Forum Thread, on the dotnetpanel forum, to gather feedback from the CF community for dotnetpanel to add ColdFusion support to their Control Panel product. To anyone out there that acts as a hosting provider, and even to you CFers who've been waiting on lower cost ColdFusion hosting, I urge you to stop by their site and put in your vote.

Upcoming Book: Learning ExtJS

I've been rather quiet for quite a while now. I have a rather large side project I've been working on, written entirely with an ExtJS front-end and ColdFusion on the back-end. I'm hoping to get that into a QA phase in the next week or two. I also just celebrated my 39th birthday, my 8th wedding anniversary, my daughter is the rock star of the 1st grade (pulling straight A pluses in every category), and the holiday's are coming.

On top of everything else, I'm putting the final touches on Learning Ext JS, to go to press at the end of the week/beginning of next, and due out in December. I've stayed relatively quiet on this, as I wanted to wait until PackT, my publisher, officially released information on the book. Let me start by saying that a few years ago I never would have thought I'd be doing this much client-side development again. And I definitely wouldn't have imagined me contributing to a book about client-side development.

I began looking at ExtJS quite a while back, while contemplating how to "jazz up" and modernize some dated interfaces I was supporting. I thought that ExtJS was an exceptionally well thought out library of rich, consistant components and functionality. While I use JQuery almost exclusively for DOM queries and manipulation, I really didn't find enough consistency in the visual plugins at the time (this has improved with the latest round of the JQuery UI plugins). I began to learn of the real power of ExtJS, and became an even bigger fan when it was announced that Adobe was including it in Scorpio, the codename for ColdFusion 8, Adobe's first implementation of the ColdFusion web application platform since it's acquisition with the Macromedia merger. Sweet! A total win-win for me.

Back in June, PackT contacted me. It seems they had started to develop a book, but the primary author, Shea Frederick, had gotten bogged down in other commitments before being able to complete the project. Some Googling on their part led them to Colin Ramsay and myself, through Cutter's Crossing. So they contacted me to find out if I was interested. The timing on this was awful. I was just starting the previously mentioned side project, my daughter was on her very first summer vacation, and just a lot of things going on. But it was too good to pass up. Aside from the fame and glory (yeah, right!), I knew that there weren't any other books out there on ExtJS, and it would be an excellent book to get out there for all the people trying to learn this exciting library. After talking the pros and cons with Aaron West, and getting sign off from my family, I finally contacted the Jedi himself, Ray Camden, to get some info on the writing process. We talked about time (a lot), commitment (more), and fame (maybe a little) and fortune (nearly none). I finally went ahead and said I would do it.

So, here it is almost six months later. I took on the final three chapters of the book: working with data stores (think like browser cached data table sets), extending Ext objects to build your own custom components, and the book wrap-up, which covers all the little stuff many people miss because they aren't typically visible. Only one chapter has any server-side code (the data stores). PackT originally wanted to convert my ColdFusion examples to PHP, to conform with the rest of the book. This morning the publisher told me that they want to keep my ColdFusion examples, to show that the ExtJS library can work with any server-side technology.

So, they're taking pre-order now, just in time for the holidays. Let me know what you think.

Our 44th...

To all of my friends, family, and colleagues who voted for our new President Elect, Congratulations. It is my sincerest hope, wish, and prayer, that in the coming four years I never have to say "I told you so."