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

Adobe CFSummit 2024 Recap | Ortus Solutions

Adobe CFSummit 2024 Recap | Ortus Solutions

A huge thank you to everyone who visited our booth! We had the pleasure of engaging in meaningful conversations about Modern CFML and ColdFusion development, sharing insights, and exploring exciting new ideas. Visitors also got a chance to participate in some fun activities and win fabulous prizes, including our customized t-shirts, which were a huge hit!

Maria Jose Herrera
Maria Jose Herrera
October 02, 2024
BoxLang September Newsletter

BoxLang September Newsletter

Welcome to the September edition of the BoxLang Newsletter! This month has been packed with exciting updates, new features, and enhancements that continue to shape BoxLang into a robust and versatile programming language. In this edition, we highlight the latest beta releases, new integrations, and key features that have been introduced.

Maria Jose Herrera
Maria Jose Herrera
October 01, 2024
Fall Savings: Unlock Exclusive Discounts Until October 31st!

Fall Savings: Unlock Exclusive Discounts Until October 31st!

Get ready for the Ortus October Fall Savings! This is your opportunity to elevate your development experience with fantastic offers designed for everyone—from seasoned developers to tech enthusiasts. Our special promotions are here to help you achieve your goals while saving money!

Don’t Miss Out on These Amazing Offers!

Use the code FALLSAVINGS24 at checkout to enjoy these incredible discounts before they expire on October 31st

Cristobal Escobar
Cristobal Escobar
October 01, 2024