Title: An%20Introduction%20to%20Fusebox%204
1An Introduction to Fusebox 4
- If written directions alone would suffice,
libraries wouldn't need to have the rest of the
universities attached. - Judith Martin (aka "Miss Manners")
2State of Fusebox
- The last two years have seen
- increased corporate acceptance of Fusebox
- increased developer acceptance of Fusebox
- increased demand in job postings for Fusebox
- no new version of Fusebox
3Fusebox What's in it for the client?
- Less risk in software projects
- Greater "project visibility"
- Not locked into a non-standardized framework
4Fusebox What's in it for managers?
- Reduces costs of deployment
- Reduces cost of tools and training
- Allows better allocation of resources
5Fusebox What's in it for me?
- Helps good programmers produce great results
- Lets you distinguish yourself from your
competition - Helps stop the madness
6FB4 It's all new!
- XML file defines overall application parameters
Fusebox.xml - XML file defines individual circuits Circuit.xml
- a permissions attribute for fuseactions
- Plugins allow developer extensions of core
Fusebox - Content components
- Change in way layouts are handled
- Parsing cycle
7FB4 It's just the same!
- Core files process a fuseaction request
- Circuits provide logical groupings of fuseactions
- Fuses hold the code
- dsp for display
- act for action
- qry for query
- lay for layout
8Building a simple FB4 app
9Download/install the FB 4 core files
10Add a circuits/Users directory
11Write Fusedocs
12Write fuses qryAllUsers.cfm
- ltcf_querysimgt
- AllUsers
- userID,firstName,lastName,newsletters
- 100StanCox19
- 200Haywood U.Buzzoff5
- 300MargeInoferror11
- lt/cf_querysimgt
13Write fuses dspUserList.cfm
- lth2gtUser Listlt/h2gt
- lttable border"0"gt
- ltcfoutput query"AllUsers"gt
- lttrgt
- lttdgtltstronggtlta href"self?fuseactionxfa.edit
UseruserIDuserID"gtlastNamelt/agtlt/stronggt,f
irstNamelt/tdgt - lt/trgt
- lt/cfoutputgt
- lt/tablegt
- ltbrgt
- ltcfoutputgt
- lta href"self?fuseactionxfa.newUser"gtNew
userlt/agt - lt/cfoutputgt
14Write fuses qryNewsletters.cfm
- ltcf_querysimgt
- Newsletters
- newsletterID,newsletterName
- 1Journal of Misanthropy
- 2Today's Mendicant
- 4Spotlight on Great Managers
- 8WaffleWorld
- 16GeekWeek
- lt/cf_querysimgt
15Write fuses qryUserInfo.cfm
- ltcf_querysimgt
- AllUsers
- userID,firstName,lastName,newsletters
- 100StanCox19
- 200Haywood U.Buzzoff5
- 300MargeInoferror11
- lt/cf_querysimgt
- ltcfquery dbtype"query" name"UserInfo"gt
- SELECT FROM AllUsers WHERE userID
attributes.userID - lt/cfquerygt
16Write fuses dspUserInfoForm.cfm
- ltcf_lth2gtUser Profilelt/h2gt
- ltcfoutputgt
- ltform action"self?fuseactionxfa.submitForm"
method"post"gt - lttable border"0" align"left" width"500"gt
- lttrgt
- lttd align"right"gtFirst name lt/tdgt
- lttdgtltinput type"Text" name"firstName"
value"UserInfo.firstName" /gtlt/tdgt - lt/trgt
- lttrgt
- lttd align"right"gtLast name lt/tdgt
- lttdgtltinput type"Text" name"lastName"
value"UserInfo.lastName" /gtlt/tdgt - lt/trgt
-
17Write fuses dspUserInfoForm.cfm
- lttrgt
- lttd align"right"gtNewsletters lt/tdgt
- lttdgt
- ltcfloop query"Newsletters"gt
- ltinput type"Checkbox" name"newsletters"
value"Newsletters.newsletterID" ltcfif
BitAnd(Newsletters.newsletterID,
UserInfo.newsletters)gt checkedlt/cfifgtgt
newsletterNameltbrgt - lt/cfloopgt
- lt/tdgt
- lt/trgt
- lttrgt
- lttd colspan"2" align"center"gt
- ltinput type"Submit" value" ok " /gt
- lt/tdgt
- lt/trgt
-
18Write fuses dspUserInfoForm.cfm
- lt/tablegt
- ltinput type"Hidden" name"userID"
value"UserInfo.userID" /gt - lt/formgt
- lt/cfoutputgt
-
19Write fuses qryUserInfoEmpty.cfm
- ltcf_querysimgt
- UserInfo
- userID,firstName,lastName,newsletters
- """"""0
- lt/cf_querysimgt
-
20Write test harnesses!!!
- Make sure that all your fuses fulfill their
contract - For this, you will need to use the Fusedocs
21Define how/what fuseactions the Users circuit
will handle circuit.xml
- ltcircuit access"public"gt
- ltfuseaction name"list"gt
- ltxfa name"editUser" value"Users.edit" /gt
- ltxfa name"newUser" value"Users.new" /gt
- ltinclude template"qryAllUsers.cfm" /gt
- ltinclude template"dspUserList.cfm" /gt
- lt/fuseactiongt
-
- ltfuseaction name"edit"gt
- ltxfa name"submitForm" value"Users.doEdit" /gt
- ltxfa name"home" value"Users.list" /gt
- ltinclude template"qryNewsletters.cfm" /gt
- ltinclude template"qryUserInfo.cfm" /gt
- ltinclude template"dspUserInfoForm.cfm" /gt
- lt/fuseactiongt
-
-
22Define how/what fuseactions the Users circuit
will handle circuit.xml
- ltfuseaction name"new"gt
- ltxfa name"submitForm" value"Users.doNew" /gt
- ltxfa name"home" value"Users.list" /gt
- ltset name"dsn" value"OurApp" /gt
- ltdo action"query.getNewsletters" /gt
- ltinclude template"dspUserInfoForm.cfm" /gt
- lt/fuseactiongt
-
- ltfuseaction name"doEdit"gt
- lt/fuseactiongt
-
- ltfuseaction name"doNew"gt
- lt/fuseactiongt
-
- lt/circuitgt
-
-
23Define the configuration for the Fusebox
application fusebox.xml
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltfuseboxgt
- ltcircuitsgt
- ltcircuit alias"Users" path"circuits/Users/"
parent""/gt - lt/circuitsgt
-
-
24Define the configuration for the Fusebox
application fusebox.xml
- ltparametersgt
- ltparameter name"fuseactionVariable"
value"fuseaction" /gt - ltparameter name"defaultFuseaction"
value"Users.list" /gt - ltparameter name"precedenceFormOrUrl"
value"form"/gt - ltparameter name"reparse" value"true" /gt
- ltparameter name"execute" value"true" /gt
- ltparameter name"mode" value"development"/gt
- ltparameter name"parseWithComments"
value"true" /gt -
- (continued)
25Define the configuration for the Fusebox
application fusebox.xml
- ltparameter name"scriptFileDelimiter"
value"cfm"/gt - ltparameter name"maskedFileDelimiters"
value"htm,cfm,cfml,php,php4,asp,aspx"/gt - lt/parametersgt
- ltglobalfuseactionsgt
- ltpreprocessgt
- lt/preprocessgt
- ltpostprocessgt
- lt/postprocessgt
- lt/globalfuseactionsgt
- (continued)
-
26Define the configuration for the Fusebox
application fusebox.xml
- ltpluginsgt
- ltphase name"preProcess"gt
- lt/phasegt
- ltphase name"preFuseaction"gt
- lt/phasegt
- ltphase name"postFuseaction"gt
- lt/phasegt
- ltphase name"fuseactionException"gt
- lt/phasegt
- ltphase name"postProcess"gt
- lt/phasegt
- ltphase name"processError"gt
- lt/phasegt
- lt/pluginsgt
- lt/fuseboxgt
-
-
27Try it out
28The Fusebox grammar
- include
- ltinclude template"dspProducts" /gt
- set
- ltset name"dsn" value"FruitProducts" /gt
- xfa
- ltxfa name"success" value"home.main" /gt
- do
- ltdo action"home.listProducts" /gt
- relocate
- ltrelocate url"http//techspedition.com" /gt
- if
- loop
29Good Stuff in Fusebox 4
- Language/version-neutral syntax
- Extensibility through plugins
- Improved performance
- No gut-wrenching changes
- Can execute multiple fuseactions in same HTTP
request (reduces ltcfmodulegt calls) - Very flexible content components
- Less need to understand the Fusebox API
30For more info
- www.fusebox.org site and forums
- Discovering Fusebox 4 book at techspedition.com
- Classes (halhelms.com)
- FastTrack to Fusebox 4
- Fusebox Mastery class
- Fusebox Lifecycle Process (FLiP)
- Articles in "ColdFusion Developer's Journal"