Archive

Archive for the ‘ColdFusion’ Category

Building Advanced Workflows with ColdSpring at cf.Obective()

April 24th, 2010 No comments

Thanks to all the folks that came to my Advanced Workflows with ColdSpring session today at cf.Objective(). The conference this year was outstanding and I’m honored to have been chosen to speak. If you’re interested in getting the slides and code, I’ve uploaded a zip file that includes everything I used in the session.

Embracing “New” in ColdFusion 9

April 16th, 2010 13 comments

I’m not sure how I missed this before but among the long list of things added to ColdFusion 9 is the ability to create a CFC using the “New” syntax. Up until now, to create a new object from a CFC we’d use the createObject() method like so

<cfset Team = createObject("component", "model.Team") />

Now, using the New keyword, we can shorten that to

<cfset Team = New model.Team() />

But wait, there’s more!
When you use the New keyword, ColdFusion will automatically look for and run any init() method that exists in the CFC. It also respects any arguments that your init() method specifies, meaning that if you have a Team.init() method that can accept team name, color and manager arguments, you can build them right into your the same line of code used to create your object like so

<cfset Team = New model.Team( "Bumblebees", "Yellow", "Benny Bee" ) />

Likewise, as you’d expect, named arguments are still supported. So if you had to send in arguments out of order or needed to omit some optional arguments at object creation, you could do

<cfset Team = New model.Team(
              manager="Benny Bee",
              color="Yellow",
              name="Bumblebees") />

I personally am going to make a point to start using this in my code because I can never seem to spell the word “component” correctly in the createObject() method.

Categories: ColdFusion

My ColdFusion Anniversary

March 18th, 2010 No comments

Well, not quite yet, but since I’m going to be out of pocket the next several days, I wanted to put this out now. Monday, March 22 will mark 10 years since I began my “journey” with ColdFusion. That day in 2000 was my first day in a class called “Fast Track to ColdFusion”.

The class was taught by Sean Hedenskog in San Jose, CA where the headquarters for the company I was working for at the time was located. That company had decided on Allaire Spectra 1.0 as the basis for an enterprise content management system so several of us went through the Fast Track to ColdFusion course in preparation for Spectra training some weeks later.
Read more…

Categories: ColdFusion

Be careful with the ‘local’ scope when migrating from CF8 to CF9

February 8th, 2010 9 comments

One of the really nice “fixes” included in ColdFusion 9 from a developer’s perspective is the inclusion of an implicit “local” variable scope into which variables created within the body of a <cffunction> tag are placed by default. Previously, developers had to manually add a “var” keyword to variables that should only exist within the confines of the function.

One of the ways of simplifying this that gained some traction among various developers prior to the release of ColdFusion 9 was to “var” a single variable at the top of the function as an empty structure then store any additional variables needed in the function inside it. Many folks, myself included, named this structure “local” so that it would be readily apparent that the values inside were local to that function. This approach worked fine and dandy on ColdFusion 8 and below.
Read more…

Categories: ColdFusion, Javascript

ColdFusion 9 caching settings to watch out for

January 31st, 2010 1 comment

Like a lot of developers, I’ve got this pet project I’m working on in whatever spare time I can find between client engagements, home maintenance, family obligations, etc. I’m using it as an opportunity to work with some of the new features of ColdFusion 9 (ORM mainly), ColdFusion Builder Beta and features in development for the next release of ModelGlue 3.

Recently, Bob Silverburg has been working on a significant overhaul of the scaffolding feature used by ModelGlue to automatically create CRUD forms for the various data objects in your application. Particularly exciting to me is that you can now override the built-in code templates with your own. Bob wrote a proof-of-concept application that uses the excellent cfUniform custom tag library to build standardized forms and validations (see my previous post on cfUniform if you’re not familiar with it). Since I’m pretty particular about how my project files are arranged, I proceeded to place the css, javascript and image assets into the folders where I wanted them and use ColdSpring to create a configuration bean to pass to cfUniform when I called it. That’s where the trouble began.

I had to make a couple of changes to the code generated in the custom scaffold CFC in order to have cfUniform see the custom configuration that I had set up. No matter what I did, when the scaffolding engine generated the code for the view and the XML fragment for the event-handler, the changes I made inside the CFC weren’t included. I spent a couple hours scratching my head, tracing the request cycle, restarting my local ColdFusion instance and always got the exact same code that was in Bob’s original example CFC. Finally, I decided to change the name of the CFC and update the associated bean configuration in ColdSpring. On the next refresh, I saw my changes reflected in the code generated by the scaffold!

With that in mind, I checked the settings on the Caching page of that instance’s CF Administrator. Sure enough, the Cache Template In Request, Component cache, and Save class files options were checked. I cleared those check boxes, pressed the Clear Template Cache Now and Clear Component Cache Now buttons below and have had no trouble since. Obviously there are situations where you want these enabled, but rarely ever should they be needed on a local system being used for development.

So, the moral of my painful story–if you’re making changes to code that’s not being reflected when you test browse your application, don’t forget to check the settings on the Caching page in CF Admin. It just might save you a couple hours and a few gray hairs.

Categories: ColdFusion, ModelGlue