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 http://cfscaffold.riaforge.org . 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.
There is a sample application included in the download. It's contained in demo.zip, and is the same one you can see at http://www.clarke.ca/cfscaffold. 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 http://www.clarke.ca/cfscaffold. 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.