Blog

Brad Wood

August 23, 2012

Spread the word


Share your thoughts

The methods in your handlers (actions) have always accepted the "event" object, which is the request context for that event and contains things like the request collection and private request collection.

A common handler method used to look like this:

function index(event) {
  var rc = event.getCollection();
  var prc = event.getCollection(private=true);
  // Do Stuff
}


Remember, if you're using ColdBox 3.1 or higher, every action is now passed a reference to the request collection (rc) and private request collection (prc) as arguments so you don't have to get them yourself.

function index(event,rc,prc){
  rc.foo = "Isn't this convenient?";
  prc.bar = "Yes, yes it is.";
}


Remembering this tip can help clean up your code by omitting those uneccessary boilerplate lines of code to get the rc and prc.

More info here: http://wiki.coldbox.org/wiki/EventHandlers.cfm#Anatomy_of_an_Event_Handler_Action

Add Your Comment

Recent Entries

BoxLang 1.0.0 Beta 27 Launched

BoxLang 1.0.0 Beta 27 Launched

We are excited to bring you Beta 27 with enhanced XML handling, new CLI app support, improved error handling, and expanded interoperability with Java and CFML runtimes. We've also added new HTTP event hooks, improved caching strategies, and a streamlined class resolution process to make your applications more performant, even in debug modes.

Luis Majano
Luis Majano
January 31, 2025
Into the Box 2025 | Plan Your Trip With Us!

Into the Box 2025 | Plan Your Trip With Us!

Are you ready to join us for Into the Box 2025 from April 30th to May 2nd in Washington, D.C.? Let’s make your trip planning as smooth as possible. Here you’ll find Airfare discounts, Hotel Deals and fun things to do to the the best out of your trip to D.C.

Maria Jose Herrera
Maria Jose Herrera
January 30, 2025