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


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.

Recent Entries

CBSecurity 3.1 Released

CBSecurity 3.1 Released

We are happy to announce our first minor release for CBSecurity v3.1.0, with some nice updates and a new password generator.

Luis Majano
Luis Majano
February 20, 2023