Tech Rocks


An online resource for latest web technologies like Coldfusion, JRun, Pro*C, JQuery, HTML5, PHP, W3C, Java, J2EE, C, C++, ORACLE, PL/SQL, MySql, Ajax, Coldbox, Fusebox, UNIX, JavaScript, NodeJS and much more...

Wednesday, November 19, 2008

Fusebox 5.5 Updated

Page Redirrection

Page Redirrection" />
Example usage in Tasks.cfc: action="time.act_addtask" ) />
This will redirect to index.cfm?


function list(myFusebox,event) {if (event.valueExists(’user_id’) {event.setValue(”reminder_user_id”,event.getValue(’user_id’));}”mReminders.actGetReminders”);”vReminders.dspListReminders”, contentvariable=”content.main”);}function prefuseaction(myFusebox,event) {event.xfa(”Calender”,”Calendar.Month”);}

What is Model View Controller?
• MVC is a design pattern
• MVC is multi-tiered architecture
– Separates the data (model) from the user
interface (view)
– De-couples data access and business logic
from data presentation and user interaction.
– The de-coupling is supported by introducing
an intermediate component: The Controller.

The Model
• Model
𐂃 The domain specific representation of the
information that the application operates with.
𐂃 Most applications use a database. MVC
doesn’t specifically mention the db access
layer since it is understood to be under or
encapsulated within the Model

The View
• The View renders the model into a shape that is
suitable for interaction (usually via a user
• Multiple views can exist for a model for different

The Controller
• The Controller is the Traffic Cop, it responds to
and processes events (usually from user
• The Controller may invoke changes on the

MVC Strengths
• Cleanly separates Controlling code from display
• Allows a model to be a representation of specific
• Allows a single point of entry for all requests
– Security measures only need to be in one
• Easier to maintain.

MVC Weaknesses
• More difficult to implement from scratch.
• More work to add functionality.
• More files to work with
• Requires more knowledge of applications than
“spaghetti code”.

Fusebox and MVC
• Historically Fusebox has been about separating
the presentation and business layers.
• MVC separates the business from the
presentation layers as well.
• What’s the difference then?

Fusebox is the Controller
• Circuit.xml is the controller.
𐂃 Think about it as the traffic cop.
• Figures out what needs to be done
• Allocates the resources to do it.
𐂃 Makes the calls to the Model and Views

CFCs are the model
• CFC’s are the heavy lifting model.
• Encapsulate the business and data models.
• CFC’s can be OOP or not, doesn’t matter.

Sample Applications
• DrivingFB is a sample application, written in man
different ways.
𐂃 NON MVC – Traditional Fusebox
𐂃 Fusebox with MVC
𐂃 MVC with a Model composed of CFC’s
𐂃 MVC with a More OOP Model using CFC’s
𐂃 XML-Less Fusebox as an additional try.
• Note, this is not the end all. Its an extra

Switching to MVC
• Driving FB_2
𐂃 No fuses were changed in the creation.
𐂃 Only the circuits were changed.
𐂃 Calls to rather than
𐂃 Models don’t have to mimic circuits.

Using CFCs as the Model
• DrivingFB_3
• All model fuses were ported to functions within a
– Model/car.cfc contains all model/car fuses
– All functions were reworked to return values.
• Controllers had to be changed to call functions.
– Also can explicitly show what each call

XML-less Fusebox
• In 2007, Team Fusebox and Teratech
conducted a survey.
𐂃 It turns out many people are still using
Fusebox 3 and one of the reasons for that
was the perceived barrier to entry of using
𐂃 Fusebox 5.5 allows for a no-xml option.

No-xml Fusebox is Fusebox light
• No ability to work with plugins
• No ability to work with lexicons
• No ability to nest circuits

Eliminating the xml files
• In index.cfm or Application.cfc implicit circuits
must be enabled
– FUSEBOX_Parameters.allowImplicitFusebox = true
• Circuits are either subdirectories or CFC’s.
• All aliases must be uniquely named.

MyFusebox object
• Contains the functions necessary to implement
xml-less Fusebox.
𐂃 myFusebox.setSelf(“self”) – Sets self
𐂃 myFusebox.getSelf() – Gets self Variable
𐂃 myFusebox.setmySelf(“self”) – Sets
myself Variable
𐂃 myFusebox.getmySelf() – Gets myself

MyFusebox Object
• myFusebox.relocate(url=“”,xfa=“”,addtoken=

Using cfm files in a Directory as fuseactions
• Name of the directory is the circuit name
• Name of the file is the fuseaction name.

Using Cfcs as Fuseactions
• CFC Name is the Circuit
• Function name is the Fuseaction.
𐂃 Two arguments are passed to each function
• myFusebox (contains the MyFusebox object)
• Event (contains an object which works with the
attributes scope)
• Don’t put output (Views) in a CFC. Instead use
the separate file technique mentioned earlier.

Event Object – Most used.
• Event.getAllValues() – gets entire attributes
• Event.setValue(“name”, “value”) – sets a
variable in the attributes structure to the
• Event.getValue(“name”) – Retrieves the
requested value from the attribute structure.
• Event.valueExists(“name”) – Check if a
requested value is present.
• Event.xfa(“name”,”value”) – Sets an eXit
FuseAction (in variables scope)

Sample CFC Fuseaction
Pre and Post Fuseactions
• Both the directory driven and CFC driven circuits
may have pre and postfuseactions.
• Directory driven:
𐂃 prefuseaction.cfm and postfuseaction.cfm
• CFC driven:
• Fusebox
𐂃 Fusebox Website
𐂃 Fusebox 5.5 Release Documents -

Download for more details
releasenotes550.pdf download


Post a Comment