Fusebox and Application.cfc
July 23, 2007 · 8 Comments
I've seen this trip a few people up to the point that it is pretty much becoming an FAQ item so I figured I'd blog it.
Scenario:
You download the Fusebox 5.1 core files and then you download the Fusebox 5.1 skeleton application and then you start to build the skeleton into a real application and you decide to convert the supplied Application.cfm file to an Application.cfc file because you're a modern CFML developer.
Symptom:
Session variables don't work in your application!
Solution:
Remove the <cfapplication> tag from the skeleton application's index.cfm file.
Problem explanation:
As supplied - and following a long, historic tradition with Fusebox - the Application.cfm file contains only logic to trap requests to non-index.cfm files and perform a redirect. That's how Fusebox applications ensure you can't request any other CFML files.
The "real" application starts with index.cfm and that begins with a <cfapplication> tag that defines the application name, session management parameters etc.
When you add Application.cfc, you're overriding Application.cfm but if you pick a different application name, e.g., this.name = "myFuseboxApp"; then index.cfm promptly resets the application name and session variables set in onSessionStart() are part of a different "application" to those within the Fusebox application.
This will be addressed in Fusebox 5.5 which will provide integration with Application.cfc out of the box.
Tags: coldfusion · fusebox

8 responses so far ↓
1 Peter J. Farrell // Jul 23, 2007 at 8:20 PM
You dogged me on that for a while with Mach-II last fall so it only seems in good jest to dog you back. ;-)
2 Sean Corfield // Jul 23, 2007 at 8:30 PM
The reason for Application.cfc support in Fusebox 5.5 is because XML will be optional and without XML there is no hook for the global fuseactions. Now, fusebox.appinit.cfm and fusebox.init.cfm are still available but nothing matches the postprocess fuseaction. Given that most people using Fusebox 5.5 without XML will - I believe - write their circuits / controllers as CFCs, allowing them to use Application.cfc easily seems the better approach.
Support for Application.cfc is not in the Alpha (released to the fusebox5 Yahoo! list) but will be in the public Beta that will be available shortly.
Your own Application.cfc will extend fusebox5.Application and, if you override onApplicationStart() or onRequestStart(), you'll need to call the super method. I'm still looking at the implications of trying to call myFusebox.do("somecircuit.someaction") within Application.cfc :)
3 Calvin // Jul 24, 2007 at 8:44 AM
4 Sean Corfield // Jul 24, 2007 at 10:25 AM
5 uranio255 // Feb 10, 2008 at 9:59 AM
So what is the solution for this?
6 Sean Corfield // Feb 10, 2008 at 10:57 AM
7 Sid Wood // Apr 29, 2008 at 8:01 AM
8 Sean Corfield // Apr 29, 2008 at 8:14 AM
Leave a Comment