Fuse Box
Fuse Box
Prerequisite Understanding:
<cfinclude>
<cflocation>
<cfswitch> / <cfcase>
<cfapplication>
Variable scopes:
session/client/application/request/attributes/ca
ller
Custom tags
URLToken
<cf_formURL2attributes>
<cfinclude template=“app_globals.cfm”>
<cfparam name=“attributes.fuseaction” default=“login”>
<cfswitch expression=“#attributes.fuseaction#”>
<cfcase value=“login”>
<cfif blah>
<cf_do_logic>
</cfif>
<cfinclude template=“dsp_UserLogin.cfm”>
</cfcase>
....
</cfswitch>
This is
Meant to
Be Just text
That isn’t
Clear. I hope
It works the cf_do_logic
(model)
Way I want
It to.
Fusebox
(controller)
This is
Meant to
Be Just text
That isn’t
Clear. I hope
It works the
dsp_UserLogin.cfm
(view)
Way I want
It to.
HTML Returned
Create the Fuseactions
A Fuseaction may cfinclude Determine what steps are
.htm/.cfm; cfmodule; needed to complete each
cflocation; contain limited Fuseaction
cfml
Add those steps inside each
A Fuseaction may NOT
display anything to the cfcase statement
browser or contain “open”
<cfcase value=“MainPage”>
SQL
<cfif client.IsLoggedIn>
<cflocation url=“index.cfm?fuseaction=login”>
<cfelse>
<cfinclude template=“dsp_HomePage.cfm”></cfif>
</cfcase>
<cfcase value=“InsertRecord”>
<cfinclude template=“act_InsertNewEmployee.cfm”>
<cfmodule template=“conf/index.cfm?fuseaction=main&ID=7”>
</cfcase>
File Naming Conventions
(Fuses)
app_globals.cfm – File defines variables, instantiates
application
request.mainDSN, request.webroot, request.mypath
<cfif not IsDefined(“application.applicationname”)>
<cfapplication name=“blah”></cfif>
dsp_filename.cfm - Display file
Only file that contains HTML or any output to browser
act_filename.cfm - Action file
Only file allowed to perform actions on the database –
updates, inserts, deletes, selects allowed, but only in
conjunction with action
qry_filename.cfm - Query file
Extremely modular file can be called “willy-nilly”
throughout application, performs selects on database
Fusedoc Documentation
Standard
A Fusedoc outlines responsibilities, customizations, and
expectations of fuses, and is unique to each fuse
No fuse can assume the existence of any variable unless
it is noted in the Fusedoc for that fuse
Once completed, a Fusedoc should provide all the
information needed to code the fuse – no interaction
with application architects or previous specifications
should be needed
A Fusecard contains the following elements:
Name of the file
Examples:
--> CurrentUser: a WDDX STRUCTURE
<-- [badLogin]: optional, a STRING
<++ Session.ColorChoice: a STRING (Red|Blue)
<-> UserID: an INTEGER
+++ myGlobals.cfm
Create the Necessary Fuses
Because the Fusedocs are so carefully built, and the design so
thoroughly thought out, individual fuses can be “farmed out”
for coding
Remember – all links and form actions go to index.cfm,
specifying which Fuseaction to perform; never to the specific
<a href=“index.cfm?fuseaction=startCheckout”>
dsp or act files.
Javascript:window.location=‘index.cfm?fuseaction=Buy’
<form action=“index.cfm?fuseaction=NewProduct”>
or
<input type=“hidden” name=“fuseaction” value=“NewProduct”>
<frame src=“index.cfm?fuseaction=BuildLeftFrame”>
Version 2: Putting It All
Together
One entire application is made up of many
smaller circuit applications
One circuit application is made up of a
directory of files
Each circuit must contain an app_locals.cfm
and index.cfm file plus other
display/action/query files as Fuses
One index.cfm file is made up of one or more
Fuseactions
One Fuseaction includes one or more
display/action/query files plus any necessary
CFML logic
Extended Fusebox: Putting It All
Together
Version 2 calls for multiple Fuseboxes to be tied together
with cflocation or cfmodule
Version 3 ties Fuseboxes together with cfincludes ONLY
There are no longer “circuit” and “home” apps – all
index.cfms function standalone – loosely coupled
Any Fusebox can cfinclude any other Fusebox without
knowing or caring what variables are used or what the
Fusebox’s architecture is
When the Fuseboxes are collected, they are called from the
highest Fusebox only using “dot-notation” href and form
action
All hrefs and form actions call the current index.cfm which,
when Fuseboxes are cfincluded, means the highest Fusebox in
the chain, without having to recode links
<a href=“index.cfm?fuseaction=catalog.view&ID=3&cat=2”>
<a href=“catalog/index.cfm?fuseaction=view&ID=3&cat=2”>
But this Fusebox can in turn, be called by a higher
Fusebox…
Extended Fusebox Code
<cfswitch expression=“#listfirst(attribs.fuseaction,“.”)#”>
<cfcase value=“cat”>
<cfset attribs.fuseaction=listRest(attribs.fuseaction,“.”)>
<cfinclude template=“../dir/cat/index.cfm>
</cfcase>
<cfcase value=“members”>
<cfset attribs.fuseaction=listRest(attribs.fuseaction,“.”)>
<cfinclude template=“/apps/index.cfm”>
</cfcase>
<cfcase value=“Info”>
<cfinclude template=“qry_ExCheck.cfm”>
<cfinclude template=“dsp_FormPage.cfm”>
</cfcase>
</cfswitch>
Fusebox Glue
<cf_bodycontent> / app_layout.cfm
<cf_formURL2attributes>
Application.cfm security
<cfif ListLast(GetTemplatePath(),'\') is not
“index.cfm”>
<cflocation url="/index.cfm?fuseaction=logoff2">
</cfif>
<cf_returnfuseaction>
app_server.cfm
Search-engine safe URLs via modified cf_formurl2attributes
<a href=“index.cfm/fuseaction/main/ID/8/cat/9.cfm”>
Verity friendly Fusebox in the works (store content in
database)
Exit Fuseactions (XFA)
Fusebox: The Final Word
Fusebox is nothing radical – sophisticated, large
applications use the MVC approach, whether CGI,
Java/J2EE, C++, PHP, ASP, etc
No one owns Fusebox – it will evolve and grow to
meet any need or new technology
Plug-n-Play saves you tons of time (time=money)
Other choices exist – but Fusebox is the proven
solution
Purchase completed applications or cut-n-paste
old code
Fusebox Resources
www.fusebox.org - home, sites using Fusebox
www.boxofuses.com - version 3 application sales
repository
www.houseoffusion.com - mailing list
www.halhelms.com - primers and Fusedocs
www.webthugs.com/consulting - frames
www.fuseml.org - home of fUseML
www.secretagents.com - tutorials and tools
www.grokfusebox.com - IRC info and archives
www.fusionauthority.com - purchase Fusebox book