FW1 is a lightweight MVC framework for ColdFusion that uses convention over configuration. It follows a section-item structure where functionality is based on the action value, which consists of a section and item. Views contain the UI and little dynamic code, and are stored in folders by section. Layouts wrap views and can render headers, footers, and navigation. Controllers contain logic and call services, which are decoupled from FW1. The request context acts as the main data bus through the application. FW1 supports subsystems, bean factories, and inversion of control/dependency injection.
4. 4
MVC Frameworks
• Fusebox - www.fusebox.org
- Oldest MVC framework
- XML config files used to define application settings in old versions.
- Not been updated since March 2008
- Fuseaction, circuit.xml, fusebox.xml
- Current Version: Fusebox: 5.5
• Mach II - www.mach-ii.com
- It was the first Object-Oriented framework for CFML.
- Event based. listeners and filters defined in XML file
- Current Version: Mach II: 1.8
• Model-Glue - www.model-glue.com
- Event-based implicit invocation OO framework
- direct integration with ColdSpring, Transfer and Reactor
- Scaffolding functionality available with ORM
- Current Version: Model-Glue: 3.2 RC
5. 5
MVC Frameworks continues..
• ColdBox - www.coldbox.org
- More than an MVC, it is a development kit and event driven
remote framework
- Rich documentation, CFB & cfeclipse tools
- Current Version: ColdBox : 3.1
• CFWheels - www.cfwheels.org
- MVC framework inspired by Ruby on Rails
- It implements the Active Record Pattern for the built in Object-
relational mapping.
- Current Version: CF Wheels 1.1.5
• FW1 - http://fw1.riaforge.org
- It is Convention over configuration MVC Framework.
- Light weight
- Current Version: FW1: 2.0 RC
6. 6
DI Frameworks
• LightWire - http://lightwire.riaforge.org
- LightWire is optimized to create transient objects as well
as singletons and allows for programmatic AS WELL AS
XML configuration.
• ColdSpring - www.coldspringframework.org
- ColdSpring is a inversion-of-control framework/container for
ColdFusion Compontents.
• DI 1 - http://di1.riaforge.org
- DI 1 is very lightweight, convention over configuration DI framework.
- Development phase, can easily integrate with FW1
7. 7
ORM Frameworks
• Transfer - www.transfer-orm.com
Main focus is to automate the repetitive tasks of creating the SQL and
custom CFCs
Developed by Mark Mandel, Great CFML contributor
Current version 1.1
• Reactor - www.reactorframework.com
Used to generate ColdFusion objects which are used to access data in
your database
• built-in ORM- www.adobe.com/orm
Hibernate is high performance OR persistence & query service.
Introduced in CF 9 & Railo 3.2
9. 9
What Is MVC
• Architectural Pattern often used by applications that need the ability to maintain multiple
views of the same data.
• Models for maintaining data.
• Views for displaying all or a portion of the data.
• Controllers for handling events that affect the model or view(s)
• Usage
Clarity
Maintainability
Reusability
Teamwork
12. 12
What is FW1
• Lightweight MVC framework developed by Sean Corfield
• Convention over Configuration . No XML
• Installing - Just extend your Application.cfc to FW1 core file
• SES URLs support
+ =
13. 13
Section & Item
• All functionality are based upon the Action value
• Action consists of a section and an item
• Section is group of items Ex. Blog, comment
• Item is a specific task inside a section Ex. List, Add, Update
Index.cfm?action=blog.list
(or)
Index.cfm/blog/add/ (SES URL)
• Default section is “Main” & default Item is “Default”
15. 15
Views
• View is a User Interaction. [Form or UI]
• View = html/css/js
• Very little dynamic code
Loops
Sets
IFs
• View Contain full page content or Fragment
• Folder per section with files named for item
• All files and folders must be in lowercase.
17. 17
Layouts
• Layout is a Wrapper. It may render Header, Footer, Navigation.
• Provided a variable named body
• Generated output that the layout should wrap
• Layout request is a cascaded action. A request can have 3 layouts executed
• FW/1 looks for layouts in the following places:
layouts/section/item.cfm
layouts/section.cfm
layouts/default.cfm
• To stop the layout cascade, use request.layout = false. It is helpful for returning XML/JSON
or AJAX calls
20. 20
Controllers & Services
• May contain a CFC for each section
• Each CFC contains a method for each item
• Caution: Cached in FW/1’s application cache!
We can clear that cache using “?reload=true” querystring. Configurable using 3 options.
reload = 'reload’
password = 'true’
reloadApplicationOnEveryRequest = false - Suitable for development phase
• Methods Cached, so function local variables is not thread safe.
So declare local variables using var
21. 21
Controllers
• Contain the high-level "traffic cop" logic
• Validation and Control flow
• commonly used functions
variables.fw.redirect()
variables.fw.service()
variables.fw.setView()
variables.fw.customizeViewOrLayoutPath()
22. 22
Services
• Intended to be agnostic of and decoupled from FW/1 conventions.
• Inside controllers you can use the service() method to manually queue calls to service
• Methods, passing the results back into the request.context.data
24. 24
The Request Context
• The main “data bus” through the application.
• Contains URL and FORM variables.
• Controller methods receive an rc argument.
• Service methods receive as argument collection.
• All Views / layouts have access to rc.
25. 25
Method execution sequence
• Called by FW1 when asked for section.item:
• Application.cfc : before()
• controllers/section.cfc:before()
• controllers/section.cfc:startItem()
• controllers/section.cfc:item()
• services/section.cfc:item()
return value stored in rc.data
• additional service calls added via service() API
• controllers/section.cfc:endItem()
• controllers/section.cfc:after()
• Application.cfc : after()
• All Methods are optional, if that do not exist are not called.
30. 30
Subsystems
• Drop an FW/1 app into an existing one
• Used as modules with no parent app dependencies
• Must enable in parent application’s Application.cfc
• usingSubsystems = true
• FW/1 Examples can be run standalone or as subsystems in another application
32. 32
Bean Factories
• Supports any bean factory (IoC Container or DI factory) with the following API methods
containsBean(name) - returns true if factory knows of named bean
getBean(name) - returns fully initialized bean identified by name
IoC - Inversion of Control
DI - Dependency Injection