ColdBox Reaches 2.6 Final Release

Posted on July 21, 2008 at 2:28 AM in ColdBox, ColdFusion

Luis Majano announced that ColdBox hit 2.6 Final Release today. This release boasts a number of new features. Here is a quick overview of some of my personal favorites:

Application-Defined Conventions

The new <Conventions> block in the coldbox.xml file allows you to define your own application directory structure.

onMissingAction() Method

This one has so many possibilities that it's mind-boggling. This really opens up the avenues to rich applications and code reuse. Just as a quick example, think about the following tasks:

  1. Add a User Email Address - index.cfm/user/addEmailAddress
  2. Add a User Phone Number - index.cfm/user/addPhoneNumber

With onMissingAction() you can now utilize a generic add() method in a utilities handler, and never even write an addEmailAddress() or addPhoneNumber() method in your user handler. When the request hits user/addEmailAddress, onMissingAction() will pick up the request where you can then define the object type and all that good stuff, and send the request over to your generic add().

SES Numeric Routes

  1. addCourse(
  2. pattern: "blog/entry/:month-numeric/:year-numeric"
  3. );

By adding "-numeric" to the :month and :year placeholders, you can know that those variables will be numeric.

SES Optional Variables

With a simple question mark (?) you can now define optional variables in your SES routes.

  1. addCourse(
  2. pattern: ":handler/:action?/:id?"
  3. );

A single route now matches three different patterns. Less code, more action. I dig it.

SES Name-Value Pairs

This one seems so simple that it's amazing that it's brand new in 2.6, but it is indeed new, and I like it. In ColdBox 2.5.x you had to either write umpteen bazillion courses (patterns), or you had to combine the base pattern (e.g. :handler/:action/:id) with your standard querystring separators (e.g. ?foo=bar). Thanks to this new enhancement, anything left over from the matched pattern will be converted to name:value pairs. Take this example:

  1. addCourse(
  2. pattern: ":handler/:action?/:id-numeric?"
  3. );

If the request is directed to

index.cfm/user/list/page/1/sort/asc

the :handler and :action? part of the course will match, but everything else (page/1/sort/asc) is "left over". Those leftovers will be converted to a variable named 'page' with a value of '1', and a variable named 'sort' with a value of 'asc'.

Summary

These are just a select few of the ColdBox 2.6 enhancements. Be sure to check out the complete What's New? list.

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 7/22/08 at 5:58 PM, ike said:

Funny, all these things have been trivially easy to do with the onTap framework for a long time *without* needing a separate special SES config file or an onMissingAction method...

granted that the upcoming (not yet released) version of the framework makes it a little easier because I made both the base template and the _process.cfm template optional, but the fundamental nature of the front-controller in the onTap framework from the very beginning, way back even long before there was such a thing as a CFC (CF5), made these things easy to do...

That's the advantage of a flexible or dynamic front-controller instead of a rigid/static "index.cfm" front-controller. Well, that and Application.cfc because otherwise you have to actually create the base templates -- onMissingTemplate allows you to omit copying those.
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

November 2024
S M T W T F S
« Oct  
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Subscribe

Enter a valid email address.

The Obligatory Wish List