Blog Updated to blogCFC 5.1.001

It took all weekend, but I was finally able to get my blog updated to the (almost) latest version of blogCFC. It looks like I wasn't the only one who had a hard time with the upgrade. Admittedly, my troubles were all self inflicted as I had quite a bit of customization to both the look and feel, and some code I had in place to manage two blogs from a single codebase.

If you don't use WinMerge, I suggest taking a look. Without a diff/merge tool like this, it would have taken me a heck of a lot longer to perform the upgrade.

So far, everything with 5.1 seems to be working ok. I had some errors from the Yahoo slurp spider trying to follow my Print links. Not sure why it's doing that as the links are clearly labeled NOFOLLOW.

Querying the DB2/400 System Catalog

DB2 stores information about database objects in what it calls the System Catalog. There are a number of views in the system catalog you can use to obtain metadata about your database such as columns, key relationships, schemas, stored procs, etc.

Today, I was working on a report where I wanted to display statistics about a number of staging files we use in our applications. I wanted to list things like number of records, number of columns, column names, etc. Things like the number of columns were easy to do just by selecting count(*) from the source table. To get the number of columns, though, I didn't want to use a hack like selecting a single record and getting the column list from that. What I wanted to do was query the system catalog. Unlike SQL Server, Oracle, and just about every other DB platform out there, documentation for DB2/400 is rather scarce.

After a lot of googling, I found a DB2/400 reference that had the information on the system catalog I needed. For those interested, the full documentation set can be found here. As IBM documentation has a tendency to disappear, here's the SYSIBM.SQLCOLUMNS library/view I used to query column information from the system catalog:

view plain print about
1<cfquery name="getColumnCount" datasource="myDSN">
2SELECT count(*) as totalRows
4WHERE TABLE_NAME = 'yourTable'

If you want to get a list of all columns, along with a lot of additional info about each column, just do a SELECT * instead of the count.

There are several other useful SQL views you can use:


CFCDev List is Back Up

Ok, that was fast. The CFCDev mailing list is now working correctly. It looks like the spam filtering was ratched up a little too tightly and was blocking some valid messages. We'll be addressing this over the next few days as we find the right balance between valid messages and spam filtering.

CFCDev List Currently Down

Just a quick note that the CFCDev list is currently down due to an issue implementing our new Spam filtering system. We're currently working on the issue and hope to have it resolved shortly.

CFUNITED: Spry Framework with Kelly Brown

Sitting in on the Spry presentation with Kelly Brown right now. He starts off by asking who attended Steve's CFAjax presentation, then making the point that Spry is (in his opinion) much easier to use. Next up is a general intro to Ajax.

The goals of Spry are open access, easy to use, and innovation enablement. Spry capabilities include loading and displaying data, filtering data using XPath, UI widgets, and visual effects. It's currently in beta, with new features still being onboarded.

Beyond the capabilities, there are some limitations. It requires JavaScript (as do all Ajax frameworks), performance (think large data sets), accessibility, and browser limitations (FireFox 1.5, Netscape 7.2, IE 6, and Safari 2.0.3), uses the Google XPath library, only supports XML data, and doesn't degrade well.

Despite limitations, Spry is pretty simple to use. You simply include a couple of JavaScript libraries, depending on what functionality you want to use. From there, you load data by creating a Spry XMLDataSet containing the URL of the data source and an XPath statement to select the data (in JavaScript). To display the data, you create a Spry region using standard HTML tags such as DIV. You use binding notation similar to Flex to do the actual display of the data:

view plain print about
1<div spry:region="mydata">
2{firstname} {lastname}

Looping is also available, similar to how it's done in ColdFusion.

Spry also has a mechanism for handling master/detail records. You can select an item from a list and have more information about that item displayed.

Kelly is moving along kinda slow, and so far the examples haven't been too dynamic. He's displaying data, but we aren't seeing much as far as dynamic data goes. So far, it doesn't look any different than just pulling data using CF and displaying on the page.

I've taken a look at one of the previous beta versions of Spry, and I do have to admit that it does seem simple to use. I still haven't gotten a good feel for everything Spry can do, and unfortunately, I'm leaving this session not much further ahead than where I started. It's nothing against Kelly - he seems pretty knowledgeable about Spry - it's just that I was expecting a slightly faster pace and a little more depth out of the presentation.

CFUNITED: CFAjax with Steve Rittler

I'm sitting in Steve Rittler's CFAjax session right now. Steve's giving some background on Ajax as well as showing the process flow. Basically, "how it works". (x)HTML uses JavaScript to talk to an Ajax object. Ajax object makes an http request to a back end system, in this case ColdFusion. ColdFusion returns xml to the ajax object, which again uses JavaScript to deal with the returned data on the client.

Besides CFAJax, there's also ajaxCFC (by Rob Gonda). It uses a slightly different approach. There are also several non-CF specific Ajax frameworks which can be used.

CFAjax works with CF 6.0 and above. Requires JavaScript. The client must also support the XMLHttp object. CFAjax can return Structs, Query's and Arrays in addition to XML.

Steve's moving into some simple examples now. It's a speaker search where you start typing a last name in a form field and Ajax is used to send the info as you type, updating the form field with possible matches. This is basically the way Google Suggest works.

Cross browser support in Ajax can be really difficult. One of the big issues Steve faced is the way most Ajax libraries require you to embed all sorts of HTML within your JavaScript. It's verbose at best. It requires DOM manipulation, which is also a huge pain for cross browser support. His solution is to use "templates". He cautions this isn't for everyone, but in their case, it works well and has a lot of real world deployments.

Pros of the templating system include returning HTML - there's no hard coded DOM work. It's also, in Steve's words "very, very, very easy". The cons are that it feels a bit dirty, and may rub purists the wrong way. Again, there's a cost benefits analysis to be done. He shows the simple example again, this time using the templating system.

Steve's mentioning upcoming Ajax trends include Ajax/Flex integration (they actually complement each other) as well as mobile Ajax.

Lots and lots of "how do I do..." questions coming from the audience. There's obviously a lot of interest in this topic. Steve's doing a good job of answering them. This presentation could definitely span multiple sessions.

Steve looks to be wrapping up with an example of how to integrate CFAjax within the Mach-II framework. It's very similar in ModelGlue as well. He's showing the demonstration from within an application his company created called RecruitWeb. It's a pretty slick application for use by athletic recruiting departments. The application is completely written in ColdFusion using Mach-II as the framework and AjaxCFC. If you are interested in the mechanics of the integration, I believe Steve is making the techniques available on his company's website, I'm sure he'd be glad to give a fuller explanation.

CFUNITED: Advanced Web Services: SOAP Headers and More with Ron West

Ron West is discussing advanced web services in ColdFusion. He's starting out by discussing some of the current problems with web services: Security, simple examples (think weather, stocks, etc), document vs. rpc.

ColdFusion uses Apache AXIS under the covers. It basically wraps the class org.apache.axis.client.stub. There are lots of useful methods you can call directly on the class. Here are a few:


WSDL isn't necessarily dynamic. In fact, you can create static WSDL files that correspond to CFC's on your system. You can also modify the static WSDL files. This lets you do things like manage endpoints. Endpoints are locations (URI) for accessing a web service. They can change during the web service call. This allows you to do things like create a simple authentication service for web services. Ron shows an example where you call one login webservice and after authenticating, it returns back the URI to use for the authenticated service. It's very simple, but it does add a layer of additional security (albeit very basic security).

SOAP headers allow you to pass additional information along to/from web services. Pre MX 7, working with headers was a real pain. In MX 7, two new functions made working with headers easier: getSOAPRequestHeader() and addSOAPRequestHeader(). SOAP headers are passed as XML. On the ColdFusion side, you can choose to work with the SOAP headers as XML or have them split out into name/value pairs.

Web services actually do support persistence (well, they support persistence of the objects being passed, but the connection itself is stateless). You can do them at the client level (via scopes in CF such as applicatoin and session) as well as the service level. AXIS has SESSION_MAINTAIN_PROPERTY as well as cookie support.

Ron then went on to show some integration examples, including one that integrated with a ColdFusion application (CommonSpot CMS) by using's web services API (it has a 3500 line WSDL!).

Overall, a very good presentation on some of the advanced ways to work with web services in ColdFusion.

CFUNITED: Inversion of Control with Dave Ross

Sitting in on Dave Ross's Inversion of Control (ColdSpring) presentation right now. Dave's laying the groundwork for the "what & why" of ColdSpring. For background, it's a framework, but not one like ModelGlue, Fusebox, Mach-II, etc. It's more like a container for your application's model. It doesn't handle HTTP requests. It's based off of the Java Spring framework, but it's not a one-for-one port. It attempts to solve the same problems, though.

ColdSpring implements a flexible model, where components use each other (one component depends on another to do work), as opposed to one component creating and configuring another. This is called a dependency, with the two components being collaborators. As an IoC container, ColdSpring injects one component into another. Components don't have to create and configure each other - they just use each other. This also makes the actual implementation unimportant as you are now programming to an interface.

Polymorphism - you can swap out one implementation of a component for another and collaborators don't know the difference.

ColdSpring works like this:

  1. Create an xml file that defines the components and their configs
  2. Refer to the content as bean definitions of bean defs - bean is interchangeable with component
  3. Create a ColdSpring BeanFactory and then pass in your bean definitions

How does ColdSpring get used in a real app:

  1. When app starts, BeanFactory is created and supplied with bean defs
  2. BeanFactory is placed in a persistent scope (application) so that the beans are singletons
  3. In an MVC app, the controller obtains the component(s) it needs from the BeanFactory
  4. ColdSpring is not usually involved with the creation of transient or value objects because that requires knowledge of the framework by other components. The main idea here is that your model shouldn't know it's being managed by ColdSpring.

BeanFactory can also do auto-wiring. Lets ColdSpring automatically figure out which components should be injected where by looking at the method signatures of the defined components and matching with bean definitions. There are pros and cons to auto-wiring. Pros are less typing and less xml. Cons are having to keep better track of what's going on.

ColdSpring AOP (aspect oriented programming). It allows you to apply a piece of code across the rest of your codebase in logical places - such as before or after a method call or when an exception is thrown. AOP is often used in logging and security, but it isn't limited to that. It also works well for managing transactions and workflow. ColdSpring AOP can also be used to expose functionality to services such as Flash Remoting without having to create a facade. Chris Scott programmed the AOP piece of ColdSpring.

ModelGlue 2.0 uses ColdSpring as the default IoC container. It's used by the framework itself and is also exposed so you can use it.

Important ColdFusion Scheduler Fix in 7.0.2

If you make regular use of scheduled tasks in ColdFusion, you'll be happy to know that a nagging, intermittnet bug has been fixed. Bug #61272 had to do with the ColdFusion schedluer firing off scheduled tasks twice after a server reboot. You can download ColdFusion 7.0.2, which contains the fix.

Personally, I only ran into this issue once on one of my production servers, but it was a big problem when it hit. We have over 600 scheduled tasks on our server which generate customer reports which are emailed out on a daily basis. Customers were irritated with receiving two copies of each report, and the additional load on our server was not desirable either.

At the time, we "fixed" the problem by deleting all of the tasks and recreating them. We scripted the bulk delete/recreate, but it was still a bit of a pain. After that, we haven't run into the issue again. I've read other reports from users with the same problem, so it's good to know a permanent fix is now available.

Reminder: CFUNITED Flickr Pool

Just a reminder for folks headed to CFUNITED (and those watching from home), there's an active Flickr Pool where you can post and view photos from the event as well as post messages. The group currently contains a lot of photos from last year's event, and I'm hoping it's just as popular this year!