Blog

Luis Majano

April 15, 2009

Spread the word


Share your thoughts

When using ColdBox's SES routing mechanisms you will come to a point where you would like to create variables depending on when a specific route matches or not.  You can do so very easily by using the argument called matchVariables, which is a simple string of name-value pairs you want to create in the request collection (This was added in version 2.6.3).  However, a hidden feature that we just documented that has been enabled since version 2.6.0, is that you can also pass named arguments to the addCourse() method and have them created on the request collection when the route matches.  This makes it much much easier to create simple or complex variables than a simple string of name-value pairs.

Example using matchVariables:

That route will create the spaceUsed,foundAt variables in the request collection when the route matches. However, let's see how easy it is to do it using by convention name-value pairs in the method. I just added the foundAt,internalNamespace, and HashMap variables just by adding them as virtual arguments. It gets even better if you are running Railo because you can use implicit Array/Structure notation to create very complex variables. Again, this is now a documented feature in the wiki, so enjoy.

Add Your Comment

(1)

Apr 16, 2009 06:49:34 UTC

by Anuj Gakhar

Thanks for documenting this. Took me a while to figure this out. I blogged as well about this. http://www.anujgakhar.com/2009/04/15/a-small-coldbox-tip/

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