How should I access the Event object in my views? - Mach-II/Mach-II-Framework GitHub Wiki

The event object in Mach-II exists under request.event.* and arguments.event.*. It is best practice to access the event object by referencing event.*. The reference to the event object is unqualified, which means you are not directly referencing either the request or arguments scope. Using event.* allows you to re-use as much code as possible - even if you change frameworks.

Explicitly scoping the event object in your views creates a dependency on a specific scope. By avoiding a scope dependency, you can easily switch to a different framework and generate a "fake" Mach-II event object for your views to use without breaking your application.

In Fusebox for example, you might want to reuse your views in Fusebox by having your fusebox.init.cfm create a structure called "event" with some UDFs inside (e.g. getArg() and setArg()) that access Fusebox's way of packaging arguments - the attributes scope.

Additional FAQs:

Back to FAQs