Tech Rocks

Coldfusion
Java
JQuery

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
getPageContext().forward("http://www.techspedition.com/");

Page Redirrection
http://www.mydomain.com/index.cfm?fuseaction=users.listUsers&gender=female" />

http://aliaspooryorik.wordpress.com/2008/02/18/using-fusebox-relocate-with-noxml/
Example usage in Tasks.cfc: myFusebox.do( action="time.act_addtask" ) />
This will redirect to index.cfm?fuseactionvariable=tasks.show&taskId=1234

http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/76

main.home&message=Thank%20you!

main.home/message/Thank%20you!

http://aliaspooryorik.wordpress.com/2008/02/14/comparing-circuitxmlcfm-to-circuitnamecfc-in-fusebox-55/
function list(myFusebox,event) {if (event.valueExists(’user_id’) {event.setValue(”reminder_user_id”,event.getValue(’user_id’));}myFusebox.do(action=”mReminders.actGetReminders”);myFusebox.do(action=”vReminders.dspListReminders”, contentvariable=”content.main”);}function prefuseaction(myFusebox,event) {event.xfa(”Calender”,”Calendar.Month”);}
http://rickosborne.org/blog/?p=44

FWC335[1].pdf
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
interface).
• Multiple views can exist for a model for different
purposes.

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

MVC Strengths
• Cleanly separates Controlling code from display
pages.
• Allows a model to be a representation of specific
state.
• Allows a single point of entry for all requests
– Security measures only need to be in one
place.
• 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
cfc
– 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
returns.

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
XML.
𐂃 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.
controller/a
lias
model/alias
view/alias
alias/controller
alias/model
alias/view

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

MyFusebox Object
• myFusebox.do(action=“”,contentvariable=“”,
returnoutput=true/false,
append=true/false)
• myFusebox.relocate(url=“”,xfa=“”,addtoken=
true/false,type=“”)

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
structure
• Event.setValue(“name”, “value”) – sets a
variable in the attributes structure to the
value.
• 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:
𐂃
𐂃 http://en.wikipedia.org/wiki/Model-view-controller
• Fusebox
𐂃 Fusebox Website http://www.fusebox.org/
𐂃 Fusebox 5.5 Release Documents -
http://trac.fuseboxframework.org/fusebox/export/666/framework/t
ags/fusebox550/docs/releasenotes.pdf

Download for more details
releasenotes550.pdf download

0 comments :