Photo from Chile

I'm Invading Your Airwaves Again

Yes, once again I've been interviewed for a ColdFusion podcast, and this time it's CFHour. Dave and Mike allowed me to wax poetically about a wide range of topics including ValidateThis, my validation framework for ColdFusion objects, the upcoming cf.Objective() conference and the pre-conference training that will be available, Model-Glue, specifically some of the new features that will be included in version 3.2, MXUnit, again talking about what's coming in version 2.0, and Dave also tricked me into weighing in on the CFBuilder debate.

It was a lot of fun, and I really appreciate being given the opportunity to let people know about all of this great stuff that is available to the ColdFusion community. If you don't mind listening to my Canadian accent for close to an hour, I encourage you to give it a listen. It's available via iTunes, and can also be listened to or downloaded directly from the show page.

Customizing Model-Glue by Overriding Framework Components

One of the cool features of Model-Glue version 3 is the ability to replace many of the components that make up the framework with your own version. This allows you to change the default behaviour of the framework (which can be useful) without having to alter any of the framework's internal code (which is a bad idea). Let's look at a situation in which we might want to customize Model-Glue and how we would do it.

Customizing Generated Code

Scaffolding is a feature of the framework that allows Model-Glue to generate working CRUD code for an object when you're using an ORM. Model-Glue 3.1 supports Transfer and Reactor, and Model-Glue 3.2 (coming soon) will also support ColdFusion 9's built-in ORM features. When you ask Model-Glue to do scaffolding for an object it will create event handlers and view templates for the operations that you request, which can include List, View, Edit, Commit and Delete. The code that is generated is based on cfcs that, by default, are found in ModelGlue/gesture/modules/scaffold/beans. The cfcs are called View.cfc, List.cfc, etc.

If we want to change the way the view template is generated for the List action, we can simply edit the file ModelGlue/gesture/modules/scaffold/beans/List.cfc, changing the code to reflect how we want our List view template to be generated.

But wait, didn't we discuss earlier that changing files within the framework itself is a Bad Thing©? No problem. Model-Glue allows you to override its own internal components by pointing to a component that belongs to your own application, which lives outside of Model-Glue's code base.

[More]