Introduction to Framework One

[email protected]

© 2011 Hotel Delta. Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License

What is FW/1?




What FW/1 is NOT ORM/Object Model Scaffolding or other CRUD Help Dependency Injector Remoting Automagicalizer Event Management, Logging, Caching, . . .

The FW/1 Philosophy

Convention over



Why Prefer Convention?

Less irritating to develop No XML means no need to do something, then tell the XML that you did it. Bonus: one fewer place for bugs to creep in.

Why Prefer Convention?

Encourages better decisions Baked-in conventions driven by community standards encourage consistent & rational code structure, force clean separation of concerns and promote shared, well-vetted practices.

Why Prefer Convention?

Fewer maintenance headaches Predictable structure lowers the learning curve and generates less code to wade through when diagnosing problems and making changes.

Installing FW/1 1. Put framework.cfc in a sensible place. (or in the root of your app)

2. Extend framework.cfc in your Application.cfc.

3. Done.

Convention: Sections & Items “Action” Defines a Section.Item

Application Section: reports Item: default

Request for section “reports” with item “conversions”

Item: conversions

Section: admin Item: default

Request for section “admin” with default item (“default”)

Item: users

Section: main Item: default

Request for default section & item (“main.default”)

Item: contact


Out-of-the-Box Support for “Search-Engine-Safe” URLs: (first two are assumed to be SECTION & ITEM - others treated as query string vars)

Section: reports

Item: conversions

Convention: File Structure Controllers Named per section with item as method names

Views Folder per section with files named for item

Layouts Global default layout + section-named files + item-named files in section-named folders (layouts cascade up from most specific to the global).

Services When using implicit service invocation (which has become somewhat unfashionable), naming scheme is same as controllers - otherwise, whatever you want.

File Structure: Simple Case

Section: about

Item: pressreleases

Controller Method pressreleases() called in the controller about.cfc

View pressreleases.cfm

in the folder about

Layout(s) Output of pressreleases.cfm in the folder about is wrapped in about.cfm is wrapped in default.cfm

File Structure: Even Simpler Case

Section: about

Item: pressreleases

Controller None.

View pressreleases.cfm

in the folder about

Layout(s) default.cfm

Convention: request.context Main “Data Bus” Used for passing information from controllers to views to layouts

Incorporates FORM and URL Vars Automatically grabs these at the start of the request - FORM takes precedence

Shorthand in Most Places: “RC” All controllers are passed the argument rc containing the request.context, and all views/ layouts have access to rc as well.

Convention: Controller Methods Order of Execution of Controller Methods (all optional)

0. init(fw)* 1. before(rc) 2. startitem(rc) 3. item(rc) 4. enditem(rc) 5. after(rc) * called once on instantiation (instance is then cached)


By convention, use startitem/enditem OR item - not both (usually start/end is used in conjunction with implicit services)

Simple Case of Request Lifecycle* action=about.pressreleases Application.cfc (extends org.corfield.framework) [setupApplication(),] [setupSession(),] setupRequest()

/controllers/about.cfc about.before(rc), about.pressreleases(rc), about.after(rc)

/views/about/pressreleases.cfm (accesses rc and has its own local scope)


(accesses view content as body - can access rc)


(accesses inner layout as body - can access rc) * doesn’t include implicit services, subsystems, or manually queued controllers/services

Manual Controller Calls controller() The controller() method can be used inside Application.cfc to queue calls to controllers other than those specified by the request’s action. All of the implicit methods will also be called for that controller item. For instance, you may want to perform authorization or some other kind of global routine in setupRequest()

You are queuing, not “calling” Keep in mind you are not actually calling a method on a controller when you use the controller() method, instead you are adding it to the queue of controllers to execute.

You cannot call controller() in a controller Once execution of the controller queue has started you cannot call controller().

Services (the most “controversial” feature of FW/1)

“Unaware” of FW/1 Services are intended to be agnostic of and decoupled from FW/1 conventions.

Implicit vs. Explicit Version 1.x of FW/1 called services implicitly by default, 2.x will not (fashion seems to lean against implicit service invocation). Implicit calls can be turned off with a true value for the “suppressImplicitService” configuration option.

Using service() Inside controllers you can use the service() method to manually queue calls to service methods, passing the results back into the request.context.

Manual, synchronous calls to services Some prefer to manually call service methods in controllers using the beanFactory interface to get at their services. Some prefer such business logic components to exist in a separate “model” folder to prevent confusion with implicit services.

Choosing The View(s) (other than the default behavior of looking for a file based on the action)

setView(“section.item”) Called inside controllers to manually set the view. If called, FW/1 will skip looking for the file based on the action.

onMissingView() Global method in Application.cfc that will handle ALL missing views (warning: also handles an error if no error view has been specified).

view(“section/item”[,args]) Called inside views and layouts to include other views. If second argument is present it is passed as the “local” scope to the included view.

variables.framework{} variables.framework = { action = 'action', usingSubsystems = false, defaultSubsystem = 'home', defaultSection = 'main', defaultItem = 'default', subsystemDelimiter = ':', siteWideLayoutSubsystem = 'common', home = 'main.default', error = 'main.error', reload = 'reload', password = 'true', reloadApplicationOnEveryRequest=false, generateSES = false, SESOmitIndex = false, baseURL = 'useCgiScriptName', suppressImplicitService = false, unhandledExtensions = 'cfc', unhandledPaths = '/flex2gateway', preserveKeyURLKey = 'fw1pk', maxNumContextsPreserved = 10, cacheFileExists = false, applicationKey ='org.corfield.framework' };

Set in Application.cfc Sets global configuration options for FW/1, allows easy over-riding of default conventions, but be careful doing that unnecessarily.

A Couple Highlights: reloadApplicationOnEveryRequest Determines if FW/1 will cache controllers/services true while developing, false in production (probably want to set dynamically based on deployment config). suppressImplicitService Defaults to false in FW/1 1.x, but will default to true in FW/1 2.x. Unless you KNOW you want implicit services, turn it off.

Other Handy Features redirect() Acts as a “smart” CFLOCATION, preserving request context if needed.

buildURL() Easy way to create URLs for links and images (etc.) based on a FW/1 action - sensitive to whether you’re using SES or not.

onMissingMethod() in Controllers Inside controllers you can define this to react to all calls from FW/1 - warning: that includes all calls to before(), after(), startitem(), enditem() - so, when using onMissingMethod you should probably define before() and after() even if empty.

request.layout You can stop the layout cascade by setting request.layout

= false

in any layout or view.

Topics Not Covered Here Subsystems Stand-alone FW/1 apps, all running under one roof.

Auto-Wiring/Bean Factories You can use ColdSpring or other frameworks to auto-wire your Controllers/Services

customizeViewOrLayoutPath() Create separate, parallel layout/view packages that can be called dynamically (great for “skins”)

populate(foo) Calls all found methods in foo matching setX(), where X is a variable in the request.context

Photo Credits •


[email protected]

© 2011 Hotel Delta. Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License

Introduction to Framework One - GitHub

Introduction to Framework One [email protected] ... Event Management, Logging, Caching, . ... Extend framework.cfc in your Application.cfc. 3. Done. (or in the ... All controllers are passed the argument rc containing the request.context, and all views/ ... Some prefer such business logic components to exist in a separate ...

631KB Sizes 20 Downloads 401 Views

Recommend Documents

Introduction to Algorithms - GitHub
Each cut is free. The management of Serling ..... scalar multiplications to compute the 100 50 matrix product A2A3, plus another. 10 100 50 D 50,000 scalar ..... Optimal substructure varies across problem domains in two ways: 1. how many ...

Introduction to R - GitHub
Nov 30, 2015 - 6 Next steps ... equals, ==, for equality comparison. .... invoked with some number of positional arguments, which are always given, plus some ...

Introduction To DCA - GitHub
Maximum-Entropy Probability Model. Joint & Conditional Entropy. Joint & Conditional Entropy. • Joint Entropy: H(X,Y ). • Conditional Entropy: H(Y |X). H(X,Y ) ...

The Coco Framework - GitHub
Aug 10, 2017 - failure. In a consortium of banks, members could be large, global, systemically important financial institutions (GSIFIs). ... End users, such as a bank's customers, do not have an identity in the Coco network and cannot transact .....

Open Modeling Framework - GitHub
Prepared for the U.S. Department of Energy, Office of Electricity Delivery and Energy Reliability, under Contract ... (ORNL), and the National Renewable Energy.

Introduction to phylogenetics using - GitHub
Oct 6, 2016 - 2.2 Building trees . ... Limitations: no model comparison (can't test for the 'best' tree, or the 'best' model of evolution); may be .... more efficient data reduction can be achieved using the bit-level coding of polymorphic sites ....

Introduction to Fluid Simulation - GitHub
upon the notes for a Siggraph course on Fluid Simulation[Bridson. 2007]. I also used .... “At each time step all the fluid properties are moved by the flow field u.

122COM: Introduction to C++ - GitHub
All students are expected to learn some C++. .... Going to be learning C++ (approved. ). ..... Computer Science - C++ provides direct memory access, allowing.

Introduction to NumPy arrays - GitHub Python. Matplotlib. SciKits. Numpy. SciPy. IPython. IP[y]:. Cython. 2015 ..... numbers and determine the fraction of pairs which has ... origin as a function of time. 3. Plot the variance of the trajectories as a function of t

An Introduction to BigQuery - GitHub
The ISB-CGC platform includes an interactive Web App, over a Petabyte of TCGA data in Google Genomics and Cloud Storage, and tutorials and code ...

Introduction to NumPy arrays - GitHub
we want our code to run fast. ▷ we want support for linear algebra ... 7. 8 a[0:5] a[5:8]. ▷ if step=1. ▷ slice contains the elements start to stop-1 .... Indexing and slicing in higher dimensions. 0. 8. 16. 24. 32. 1. 9. 17. 25. 33. 2. 10. 18.

introduction to net framework pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. introduction to ...

introduction - GitHub
warehouse to assemble himself. Pain-staking and time-consuming... almost like building your own base container images. This piggy purchased high- quality ...

Introduction - GitHub
software to automate routine labor, understand speech or images, make diagnoses ..... Shaded boxes indicate components that are able to learn from data. 10 ...... is now used by many top technology companies including Google, Microsoft,.

Introduction - GitHub
data. There are many ways to learn functions, but one particularly elegant way is ... data helps to guard against over-fitting. .... Gaussian processes for big data.

Introduction - GitHub
For the case that your PDF viewer does not support this, there is a list of all the descriptions on ...... 10. Other Formats. 10.1. AMS-TEX. AMS-TEX2.0. A macro package provided by the American .... A TeX Live port for Android OS. Based on ...

Introduction - GitHub
them each year. In an aggregate travel demand model, this would be represented as 100/365.25 = 0.2737851 trucks per day. In the simulation by contrast, this is represented as ... based on the distance traveled (Table 3.3). 2FAF3 Freight Traffic Analy

... news cycle have a history of hypocritical votes against funding. diplomacy and development, the very work these Americans died for. Questions and Answers.

Using the Xtivia Services Framework (XSF) to Create REST ... - GitHub
As we know the current trend in web application development is toward Single Page Applications (SPAs), where the majority of application functionality is ...

Course: Introduction to Intelligent Transportation Systems - GitHub
... Introduction to Intelligent Transportation Systems. University of Tartu, Institute of Computer Science. Project: Automatic Plate Number. Recognition (APNR).

Introduction to REST and RestHUB - GitHub
2. RestHUBанаRESTful API for Oracle DB querying. 2.1. Overview. RestHub was designed .... For example we want to create a simple HTML + Javascript page.

A Beginner's Introduction to CoffeeKup - GitHub
the buffer, then calls the title function which adds it s own HTML to the buffer, and ... Now it is starting to look like real HTML you d find on an ugly web page. 2 ...

Introduction to RestKit Blake Watters - GitHub
Sep 14, 2011 - Multi-part params via RKParams. RKParams* params = [RKParams paramsWithDictionary:paramsDictionary];. NSData* imageData .... This is typically configured as a secondary target on your project. // Dump your seed data out of your backend

Introduction to Scientific Computing in Python - GitHub
Apr 16, 2016 - 1 Introduction to scientific computing with Python ...... Support for multiple parallel back-end processes, that can run on computing clusters or cloud services .... system, file I/O, string management, network communication, and ...