Blog

Brad Wood

November 14, 2012

Spread the word


Share your thoughts

 

In a ColdBox request, form, URL, and remote (proxy request) variables are merged together into the request collection which is accessible via event.getCollection() or as the "rc" struct passed into every action in your handlers.  Data needed to process that request can be added and retrieved from this collection at any time during the request as it is available to any layouts and views as well.  
 
What you may not now however, is there is also a private request collection.  This one also lives in the event object and can be accessed via event.getCollection(private=true) or as the "prc" struct that is also passed into each action.  
 
So, what's the difference between the regular request collection and the private request collection?  Not much in the way of implementation.  It's all in how you use them to help organize your code.  ColdBox best practices are to reserve the regular request collection for only form, URL, and remote variables as they were received from the client.  More importantly, these are the incoming variables from your user that control how the request will process.  A good example would be the productID variable coming into a product detail page.  
 
The private collection is best used by everything else, especially if it has no direct bearing on how the page is processed.  An example could be a service that the handler wants to pass along to the view, or a result set of data that will be used in outputting the view.
 
 
P.S. One of the reasons it's ideal to only store items in the rc that control what displayed on the page is because ColdBox creates a hash of the rc at the beginning of your request which is used for event caching to ensure a different version of the event's output is cached for each combination of incoming criteria.
 

Add Your Comment

Recent Entries

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024