Andrew Clarke

systems architect, internet developer, team leader

Andrew Clarke

CFScaffold: Zero-config ORM CRUD Scaffolding for CFML

January 4, 2011 · 4 Comments


CFScaffold is a drop-in, zero configuration CRUD/scaffolding tool for CFML.  It reads the metadata in your ORM objects and uses this information to create list/create/read/update/delete capability for all of your objects.  CFScaffold does not generate code; it builds all views and performs all tasks on the fly using your objects' metadata.

What does CFScaffold do?

CFSCaffold will (hopefully) save you time when developing applications.  Writing CRUD code is time consuming.  CFScaffold can provide you with a basic CRUD application that is usable as-is and can be configured further if you desire.  Therefore, once you've defined your objects (i.e. Person, Address, etc.) you don't have anything more you need to do to start navigating those objects, filling them, editing data, etc.


I have developed CFScaffold on Railo 3.2 and that's what I use to run it.  I also tested it very briefly on ColdFusion 9 and it ran, although I haven't done extensive testing there yet.  The idea is that it should support both Railo 3.2+, and ColdFusion 9+.  You will also need to set up your objects and relationships between them (one-to-many, many-to-one, many-to-many).  That's it.

While CFScaffold requires you to create ORM objects, you don't need to write your whole application using CMFL's ORM capabilities.  In fact, you could write the entire rest of your application using "old-fashioned" SQL if you want.  You'd just need to make sure your ORM objects are kept up to date for CFScaffold to continue to work properly.


Download CFScaffold from .  Place it in a directory under your application, and then go to the CFScaffold directory.  Everything should just work.

CFScaffold does not have its own Application.cfc.  It relies on your Application.cfc in a parent directory to set up ORM.  CFScaffold will create an object called "factory" in your application scope, so hopefully that doesn't conflict with something you already have.

Sample Application

There is a sample application included in the download.  It's contained in, and is the same one you can see at  If you want to try this out on your server and look it over, unzip the files and place them in the same directory as your CFScaffold application.  You will also need to create a MySQL datasource called cfscaffold, or modify Application.cfc to change the DSN.

Check out the beans directory to view the example ORM objects.  If you're new to ORM in CFML, this will give you an example of how the objects and relationships can be set up.  The lazy="false" argument of some of the properties is due to a bug in Railo 3.2, in case you're wondering why I put that in there.

You can also view a demo of the sample application at  Feel free to mess it up as much as you want; it will be overwritten with default data every time the application reloads.


The options for modifying the look & feel of CFScaffold right now are limited, but I plan to add more options.  I've tried to add CSS classes and IDs to most of the HTML properties in the views so that you can use CSS to modify the look of the pages.  You'll find that not every HTML element has CSS classes and IDs added so far, though.

Also, objects need to be able to represent themselves as strings.  If you provide a toString() function in your objects, that will be used to represent an object.  For example, the country object has a toString() function that returns the country name.  If an object does not implement toString(), it will just take some of the data it finds in the object and write that out.  This is the sole piece of configuration that I would consider close to crucial if you're going to use CFScaffold.  I still think it's reasonable to call CFScaffold "zero configuration" as you don't NEED to implement toString(), but you'll probably want to.


Right now, CFScaffold does not implement any security checks.  You will need to put those checks in yourself.  To clarify, right now if someone knows that index.cfm?action=delete&entityName=ProvinceState&entityID=52 will delete ProvinceStateID 52, there is no check to stop them from deleting that ProvinceState.


Please email me if you have any questions, run into any problems, or have any suggestions.  I have released this code after it meets my current basic requirements, which means that as-is right now it probably won't meet yours.  I hope to be responsive to the community's suggestions if people find this useful and want to use it.

Some areas that need to be implemented or improved include:

- Paging.  There's no paging implemented, so if your object has 10,000 instances in the database, it will attempt to dump a 10,000 row table on the page.

- Object validation.  I've implemented some validation using the ORMType and validate attributes of properties.  This is partially complete, but you'll find that it currently only validates certain types.  These are just the types that I've used so far.  I validate using CFForm wherever possible, and also again on the server.  I hope to take further advantage of ColdFusion's "validate" attribute, although Railo doesn't support it which is why I haven't used it much yet in CFScaffold.

- Documentation. I haven't provided any significant documentation other than this post.  If people want it, I'll try to write it.

- Performance. I haven't tested this under heavy load, or with a large database.  I'm sure there are some performance limitations, and will get to those when they're discovered.  Probably I can utilize caching to better effect, rather than constantly querying object metadata using evaluate().

Thanks for reading, and please let me know what you think.


Tags: CFScaffold · ColdFusion · Hibernate · ORM · Railo

4 responses so far ↓

  • 1 Dan O'Keefe // Jan 7, 2011 at 12:04 PM

    is the references in this post to CFCruncher supposed to be CFScaffold?
  • 2 Andrew Clarke // Jan 8, 2011 at 2:41 AM

    Yeah, sorry! I'm getting two of my projects mixed up. I'm using CFScaffold in another project I'm affectionately calling "Cruncher". I'll update the post so no future readers will be able to figure out what we're discussing.
  • 3 David // Jul 20, 2012 at 11:14 AM

    Looks like quite a bit of effort has gone into cfscaffold -- thank you!
    I played with it a bit today and seemed to run into a problem because I am using a mappedsuperclass. At least that appears to be the issue. I have a super class with the id field in it which is extended by the classes I am persisting. When I ran cfscaffold, it threw an error that there is no id column.
    However, there is an ID column, it is just inherited from the mapped super class. Is there something I need to do to handle this?
  • 4 Andrew Clarke // Jul 20, 2012 at 11:24 AM

    Hi David. I've never tried using mappedsuperclass, so I can't really tell you specifically what the problem is. It sounds like you're on the right track though.

Leave a Comment

Leave this field empty