Blog

Brad Wood

January 11, 2013

Spread the word


Share your thoughts

 

If you've ever wanted to modify any behavior of the core ColdBox controller, you can now do so as of version 3.5.3 with the Controller Decorator feature.  This is accomplished much like the Request Context Decorator.
 
First, add a configuration setting called "ControllerDecorator" in the coldbox struct of your config file.  
 
/config/ColdBox.cfc
coldbox.controllerDecorator = "path.to.myControllerDecotrator";
 
Next, build your decorator as a CFC that extends our base coldbox.system.web.ControllerDecorator class like so.
 
/path/to/myControllerDecotrator.cfc
component extends="coldbox.system.web.ControllerDecorator"{
 
    function setNextEvent(){
        arguments.ssl = true;
        getController.setNextEvent( argumentCollection=arguments );
    }
 
}
 
That example would wrap the setNextEvent method and force it to always redirect to a secure URL.
 
 
P.S. Instead of extending a class with a super reference, the decorator pattern composes the original object in an invisible wrapper class which contains a reference to the original.  In your controller decorator, you can use the getController() method to get the original controller object.

Add Your Comment

Recent Entries

Into the Box 2024: Your Gateway to the Future of Tech!

Into the Box 2024: Your Gateway to the Future of Tech!

Are you ready to advance your coding skills? The future of Modern Web Development awaits at Into the Box 2024, and we're thrilled to announce that due to high demand, we're extending our Early Bird pricing for an additional week!

Maria Jose Herrera
Maria Jose Herrera
April 26, 2024
Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024