YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: An Introduction to Fusebox 4

An Introduction to FB4

An 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")

Page 2: An Introduction to Fusebox 4

An Introduction to FB4

State 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…

Page 3: An Introduction to Fusebox 4

An Introduction to FB4

Fusebox: What's in it for the client? Less risk in software projects Greater "project visibility" Not locked into a non-standardized framework

Page 4: An Introduction to Fusebox 4

An Introduction to FB4

Fusebox: What's in it for managers? Reduces costs of deployment Reduces cost of tools and training Allows better allocation of resources

Page 5: An Introduction to Fusebox 4

An Introduction to FB4

Fusebox: What's in it for me? Helps good programmers produce great results Lets you distinguish yourself from your competition Helps stop the madness

Page 6: An Introduction to Fusebox 4

An Introduction to FB4

FB4: 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

Page 7: An Introduction to Fusebox 4

An Introduction to FB4

FB4: 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

Page 8: An Introduction to Fusebox 4

An Introduction to FB4

Building a simple FB4 app

Page 9: An Introduction to Fusebox 4

An Introduction to FB4

Download/install the FB 4 core files

Page 10: An Introduction to Fusebox 4

An Introduction to FB4

Add a circuits/Users directory

Page 11: An Introduction to Fusebox 4

An Introduction to FB4

Write Fusedocs Omitted here for space

Page 12: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: qryAllUsers.cfm<cf_querysim>

AllUsersuserID,firstName,lastName,newsletters100|Stan|Cox|19200|Haywood U.|Buzzoff|5300|Marge|Inoferror|11

</cf_querysim>

Page 13: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: dspUserList.cfm<h2>User List</h2><table border="0"><cfoutput query="AllUsers">

<tr><td><strong><a href="#self#?

fuseaction=#xfa.editUser#&userID=#userID#">#lastName#</a></strong>,#firstName#</td></tr>

</cfoutput></table><br><cfoutput>| <a href="#self#?fuseaction=#xfa.newUser#">New user</a> |</cfoutput>

Page 14: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: qryNewsletters.cfm<cf_querysim>

NewslettersnewsletterID,newsletterName1|Journal of Misanthropy2|Today's Mendicant4|Spotlight on Great Managers8|WaffleWorld16|GeekWeek

</cf_querysim>

Page 15: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: qryUserInfo.cfm<cf_querysim>

AllUsersuserID,firstName,lastName,newsletters100|Stan|Cox|19200|Haywood U.|Buzzoff|5300|Marge|Inoferror|11

</cf_querysim>

<cfquery dbtype="query" name="UserInfo">SELECT * FROM AllUsers WHERE userID = #attributes.userID#

</cfquery>

Page 16: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: dspUserInfoForm.cfm<cf_<h2>User Profile</h2><cfoutput><form action="#self#?fuseaction=#xfa.submitForm#"

method="post"><table border="0" align="left" width="500">

<tr><td align="right">First name: </td><td><input type="Text" name="firstName"

value="#UserInfo.firstName#" /></td></tr><tr>

<td align="right">Last name: </td><td><input type="Text" name="lastName"

value="#UserInfo.lastName#" /></td></tr>

Page 17: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: dspUserInfoForm.cfm<tr>

<td align="right">Newsletters: </td><td><cfloop query="Newsletters">

<input type="Checkbox" name="newsletters" value="#Newsletters.newsletterID#" <cfif BitAnd(Newsletters.newsletterID, UserInfo.newsletters)> checked</cfif>> #newsletterName#<br>

</cfloop></td>

</tr><tr>

<td colspan="2" align="center"><input type="Submit" value=" ok " />

</td></tr>

Page 18: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: dspUserInfoForm.cfm </table><input type="Hidden" name="userID" value="#UserInfo.userID#" />

</form>

</cfoutput>

Page 19: An Introduction to Fusebox 4

An Introduction to FB4

Write fuses: qryUserInfoEmpty.cfm

<cf_querysim>UserInfouserID,firstName,lastName,newsletters""|""|""|0

</cf_querysim>

Page 20: An Introduction to Fusebox 4

An Introduction to FB4

Write test harnesses!!! Make sure that all your fuses fulfill their contract For this, you will need to use the Fusedocs

Page 21: An Introduction to Fusebox 4

An Introduction to FB4

Define how/what fuseactions the Users circuit will handle: circuit.xml

<circuit access="public"><fuseaction name="list">

<xfa name="editUser" value="Users.edit" /><xfa name="newUser" value="Users.new" /><include template="qryAllUsers.cfm" /><include template="dspUserList.cfm" />

</fuseaction>

<fuseaction name="edit"><xfa name="submitForm" value="Users.doEdit" /><xfa name="home" value="Users.list" /><include template="qryNewsletters.cfm" /><include template="qryUserInfo.cfm" /><include template="dspUserInfoForm.cfm" />

</fuseaction>

Page 22: An Introduction to Fusebox 4

An Introduction to FB4

<fuseaction name="new"><xfa name="submitForm" value="Users.doNew" /><xfa name="home" value="Users.list" /><set name="dsn" value="OurApp" /><do action="query.getNewsletters" /><include template="dspUserInfoForm.cfm" />

</fuseaction>

<fuseaction name="doEdit"></fuseaction>

<fuseaction name="doNew"></fuseaction>

</circuit>

Define how/what fuseactions the Users circuit will handle: circuit.xml

Page 23: An Introduction to Fusebox 4

An Introduction to FB4

Define the configuration for the Fusebox application: fusebox.xml

<?xml version="1.0" encoding="UTF-8"?><fusebox>

<circuits><circuit alias="Users" path="circuits/Users/"

parent=""/></circuits>

Page 24: An Introduction to Fusebox 4

An Introduction to FB4

Define the configuration for the Fusebox application: fusebox.xml

<parameters><parameter name="fuseactionVariable"

value="fuseaction" /><parameter name="defaultFuseaction"

value="Users.list" /><parameter name="precedenceFormOrUrl"

value="form"/><parameter name="reparse" value="true" /><parameter name="execute" value="true" /><parameter name="mode" value="development"/><parameter name="parseWithComments"

value="true" />

(continued)

Page 25: An Introduction to Fusebox 4

An Introduction to FB4

Define the configuration for the Fusebox application: fusebox.xml

<parameter name="scriptFileDelimiter" value="cfm"/><parameter name="maskedFileDelimiters"

value="htm,cfm,cfml,php,php4,asp,aspx"/></parameters>

<globalfuseactions><preprocess></preprocess><postprocess></postprocess>

</globalfuseactions>

(continued)

Page 26: An Introduction to Fusebox 4

An Introduction to FB4

Define the configuration for the Fusebox application: fusebox.xml

<plugins><phase name="preProcess"></phase><phase name="preFuseaction"></phase><phase name="postFuseaction"></phase><phase name="fuseactionException"></phase><phase name="postProcess"></phase><phase name="processError"></phase></plugins>

</fusebox>

Page 27: An Introduction to Fusebox 4

An Introduction to FB4

Try it out…

Page 28: An Introduction to Fusebox 4

An Introduction to FB4

The Fusebox grammar include

<include template="dspProducts" /> set

<set name="dsn" value="FruitProducts" /> xfa

<xfa name="success" value="home.main" /> do

<do action="home.listProducts" /> relocate

<relocate url="http://techspedition.com" /> if loop

Page 29: An Introduction to Fusebox 4

An Introduction to FB4

Good Stuff in Fusebox 41. Language/version-neutral syntax2. Extensibility through plugins3. Improved performance4. No gut-wrenching changes5. Can execute multiple fuseactions in same HTTP request

(reduces <cfmodule> calls)6. Very flexible content components7. Less need to understand the Fusebox API

Page 30: An Introduction to Fusebox 4

An Introduction to FB4

For 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"


Related Documents