30onair: Why ColdFusion?

At last night's Flex and AIR release celebration, Aaron brought out his new, 30onair branded, video camera for us all to record a 30onair segment. Mine was on ColdFusion (go figure;) The light was bad, and I had just gotten back from the dentist prior to the celebration, but I put my point across.

[More]

Guidelines: Code Readability - Pt1

At work I (with heavy input from the rest of the team) am writing these guidelines for our development practices, so that everyone is working 'on the same page.' I will share this series here for others who may want to know how some folks do it.

In everything there must be balance, two sides to every coin. A debate goes on about code "structure". To indent? Or not indent? One argument persists that unnecessary spaces/tabs within code increase the bandwidth used by our systems, serving up 'empty' content. The other argument is that this cost is minimal, in comparison to the time savings with relation to maintaining 'readable' code.

[More]

SQL Tricks: What's an Upsert?

So, despite the debate on utilizing an Active Record (sometimes called Table Row) design pattern, there are times when it can be incredibly useful. Especially when dealing with simple forms that deal with a single record within a table (go figure). It's also really handy if you're utilizing something like The Illudium PU-36 Code Generator to auto-generate your data modeling. But, occasionally, you hit a glitch and need to rethink.

[More]

WebManiacs 2008 Registration Open

In a previous post I mentioned that I'll be speaking in the CFManiacs portion of the WebManiacs Conference in Washington, DC, May 19 - 23. Registration for the conference is now open, with a spectacular lineup of speakers on very high-end, focused topics, covering ColdFusion, Flex, and AIR. Here's the official line from FigLeaf:

The WebManiacs 2008 conference schedule has been finalized and registration is open. Early bird pricing ends Jan 31. Consisting of a two-day ColdFusion conference ("CFManiacs") coupled with a three-day Flex conference (FlexManiacs), hosting over 70 speakers and 130 distinct topics (some of which are hands-on), WebManiacs promises to have the most comprehensive coverage of Flex, AIR, and ColdFusion at the lowest price. Seating is limited, so folks should register early in order to get into the more popular sessions.

CF8 Ajax Grid: Showing the TotalRecordCount

This morning, Paul Stewart submitted an interesting question to the CF-Talk List:

"Hi, I have been using the CFgrid tag in CF8 (format HTML, bound to a cfc), and i have got it do almost all that i need it do (see below). Except that i don't know how to get access to the TOTALROWCOUNT figure that i can see in the debugger returned from the CFC , and also be able to display that figure either on the bottom of the grid itself (using ext.toolbar???), or even above it on the page using another ajax method??.

I need to do this show the user amount of records returned from his/her search. i.e 'your search returned x number of records.' From reading Ray Camden's blog I know i have to use the underlying Ext library that the cfgrid tag is based on, and i have used his solution to format some columns in the grid (nice one Ray). But i am not really getting anywhere (hopelessly bamboozled) with the records returned figure...."

This is a great question! And so easy to implement using the underlying ExtJS 1.1.1 component architecture of the ColdFusion 8 Ajax controls. The grid component already knows what the beginning and ending rows are for the page, and the total number of rows, so it's just a matter of getting them to display on the PagingToolbar. Paul had included a little code in his post, the primary piece of which (as far as we're concerned) is his formatgrid() function:

view plain print about
1formatgrid = function() {
2 mygrid = ColdFusion.Grid.getGridObject('ad');
3
4 cm = mygrid.getColumnModel();
5 cm.setRenderer(3,myf);
6 cm.setRenderer(5,myf);
7
8 mygrid.reconfigure(mygrid.getDataSource(),cm);
9}

Basically he has most of the pieces that he needs already. He needs a reference to his data.Store object, which we'll add right after he gets his grid instance:

view plain print about
1...
2    mygrid = ColdFusion.Grid.getGridObject('ad');
3    ds = mygrid.getDataSource();
4    ...

Then, after his renderers, but before his reconfigure(), we'll get a reference to his grid's FooterPanel to redefine the PagingToolbar:

view plain print about
1...
2    cm.setRenderer(5,myf);
3    // Get the Footer
4
5    var gridFoot = mygrid.getView().getFooterPanel(true);
6    // Create a new Paging Toolbar
7
8    var paging = new Ext.PagingToolbar(gridFoot,ds,{
9        pageSize:25, //number of records displayed in grid
10
11        displayInfo:true,
12        displayMsg:'Displaying records {0} - {1} of {2}',
13        emptyMsg:"No records to display"
14    });
15    
16    // reconfigure the grid
17
18    mygrid.reconfigure(ds,cm);
19    ...

Hey! Reload the page and what do you get? An adjusted toolbar, giving Paul exactly what he was looking for, the current record from - to and the total number of records returned. Though I've used this before, I wanted to note that this code is almost an exact copy of the example code included in the ExtJs 1.1.1 API documentation. There is a ton of untapped potential within the underlying Ext framework. With a little research you may be surprised what you can accomplish.

ExtJS 2.0 Grid Gotcha

I recently upgraded all of my former ExtJS code to utilize the updated 2.0 library. There are a lot of fantastic changes and additions here, but I did run into one or two snags. In a previous post I showed how to use Event Handlers and Item Renderers with the ColdFusion 8 Ajax implementation of the ExtJS 1.1.1 data grid. It works very similarly with a straight (non-CF) implementation, whereby I had defined an unbound column, in my ColumnModel, and applied a renderer to it so that an icon would appear with an onclick event attached to the cell click. It's a very straight forward process, that immediately broke with the 2.0 library. It took me a little bit of playing around, but I finally discovered what appears to be either a bug in the library, or a glitch in the documentation.

What made this column previously 'unbound' was the fact that no dataIndex was set to the column. It wasn't required. Acoording to the 2.0 documentation, the attribute is still supposed to be optional. However, when trying this with 2.0, I found that I would continually get an error. Only after duplicating my dataIndex (I applied my ID query column to the dataIndex, the same as my ID column), and then using the renderer to overwrite, did I finally get my working grid. It's a bit of a hack, but it did the job.

It's a small gotcha, but a gotcha none the less, so I wanted to let ya'll know. As I said before, there are some fantastic changes in the new 2.0 implementation, and already some nice plugins being developed by the community. Well worth taking a peek under the covers.

Ask Cutter: Calling functions when paging the CF8 DataGrid

Yesterday, Mischa posted the following comment on my post on CF8 Ajax Grid: Renderers and Events:

Hi Steve, thank you for this example and your explanation! Do I understand correctly that init will fire once? Is there a way to fire init or any other function when the user pages through the grid using the page forward button? Thanks! Mischa.

Great question! Yes, to my knowledge the init() method is only called once. And, chances are, you really want it to only be called once. However, when the grid is initialized, and on every paging request, the data store runs it's load() method. The data store object, one of the underlying ExtJS pieces of the data grid, has a publicly available event that you can listen for, 'load'. I would go something like this.

view plain print about
1reportGrid = function(){
2    grid = ColdFusion.Grid.getGridObject('reportsGrid');
3    cm = grid.getColumnModel();
4    ds = grid.getDataSource();
5    cm.setRenderer(2,redBold);
6
7     var gridHead = grid.getView().getHeaderPanel(true);
8 var tb = new Ext.Toolbar(gridHead, [{
9 text: 'Add Art',
10 handler : showRecWin
11 }]);
12
13    grid.reconfigure(ds,cm);
14
15    ds.on('load',function(){alert('it just loaded the Data Store')});
16}

It's that last line that's the kicker. What I've done here is used the data store's on() method to assign an Event Listener to the 'load' event, with my own custom function. This will now kick off with whenever the data store calls the load() method, which happens on initialization, as well as each paging request (forwards or backwards).

There is a wealth of available knowledge, for interacting with these components, that is available in the ExtJS 1.1 API documentation. Looking at their online examples gives you an idea of how these components are built and interact, and knowing that can point you to the API documentation that will help you get the job done.

The Year In Review

2007, The Year Of The Scorpio, was a fantastic year to be a ColdFusion developer. The release of ColdFusion 8 marked a new age in web application development, with so many new features and enhancements that should see some truly outstanding next generation applications in the years to come. As a community, the CF crowd has really been flourishing, with new releases in several major frameworks, the introduction of the RIAForge open source repository for Adobe related technologies, widely publicized adjunct technologies like Flex 3 and AIR approaching final release (spawning a new conference in 2008, showcasing all three technologies together), and the premier of our own developer's social networking site, ColdFusion Community. We saw the loss of the CFDJ albatross, while the Fusion Authority Quarterly, introduced at CFUnited 2006, has truly come out as an excellent ColdFusion developer's resource. And we can't forget our very own, ColdFusion specific, blog aggregator, ColdFusion Bloggers, introducing us to so many other great developers willing to share their knowledge and experiences, like the creative, and very colorful, examples provided by Ben Nadel.

I've always felt that a day without learning is a day that your dead from the neck up.I spent quite a bit of time this year learning new things, and sharing most. I've been slowly picking up Flex, put a little research into AIR, adopted JQuery heavily, run series of posts on developing on Apache and utilizing the outstanding components of the ExtJS library (the most trafficed posts on this blog). I tried to share some of the things I had learned about the new functionality of ColdFusion 8, started posting some General Coding Guidelines I've been writing for our company, and even got some first hand experience looking at the Current ColdFusion Job Market.

I look forward to sharing more in the year to come. I always look for, and appreciate, all of the feedback you readers send my way. I think the future for ColdFusion is extremely bright, and I can't wait to see what 2008 holds for us all.

2007 CFeMmys Voting Begins

The voting has begun on the 2007 CFeMmys. Todd Sharp began the CFeMmys last year, for the ColdFusion community to vote, and recognize, those who made contributions throughout the year. Somehow, someone made a mistake, and submitted Cutter's Crossing in the 'Best Blog' category. While I won't turn down any votes, it's a bit humbling to be included in such prestigious company (man, that's twice in two weeks!)

So, don't forget to head over and vote! Voting is through this Friday at noon. The competition has nothing to worry about, I couldn't bribe anyone even if I wanted too;) Best of luck to all the nominees!

ExtJS 2.0: Extending The RowExpander Plugin

Back on the 4th of December, the ExtJS team announced the official release of ExtJS 2.0. Sorry I'm a bit late to get to this, but I've been a little busy with a move, and other fun things. I had the excellent opportunity to preview the 2.0 release in advance, and I have to tell everyone that it is outstanding, a true work of art. The team has gone out of their way to pay attention to community feedback, gather information on the features that were most needed, and writing a truly elegant implementation of this library.

[More]

Previous Entries / More Entries