Delegates
Compose ColdBox superpowers into any object via WireBox delegation
ColdBox ships with a rich set of built-in delegates that let you compose framework capabilities directly into any object — handlers, models, services, schedulers, interceptors — without extending a base class or writing boilerplate proxy methods.
Two Namespaces
ColdBox registers delegates under two WireBox namespaces:
@coreDelegates
General-purpose utilities: async, datetime, environment, flow, JSON, strings, population
WireBox (always available)
@cbDelegates
ColdBox-specific: rendering, routing, settings, interceptors, app modes, file locators, population from request
ColdBox (when running inside ColdBox)
Quick Start
// A model that can render views, read settings, and build links
class
delegates="Rendering@cbDelegates,
Settings@cbDelegates,
Routable@cbDelegates" {
function getWidget( required string name ) {
var config = getSetting( "widgets" )
return view( "widgets/#name#", { config : config } )
}
function getLink() {
return buildLink( "home.index" )
}
}// A model that can render views, read settings, and build links
component
delegates="Rendering@cbDelegates,
Settings@cbDelegates,
Routable@cbDelegates" {
function getWidget( required string name ) {
var config = getSetting( "widgets" )
return view( "widgets/#name#", { config : config } )
}
function getLink() {
return buildLink( "home.index" )
}
}Or use individual property injections when you need prefixes/suffixes or targeted method delegation:
Available Delegates
Core Delegates (@coreDelegates)
General-purpose utilities available in any WireBox-managed application.
Async@coreDelegates
Async/parallel programming via the ColdBox AsyncManager
DateTime@coreDelegates
Date and time utilities via DateTimeHelper
Env@coreDelegates
Java system properties and OS environment variables
Flow@coreDelegates
Fluent flow-control methods (when, unless, peek, throwIf, etc.)
JsonUtil@coreDelegates
JSON serialization utilities
Population@coreDelegates
Object population from structs, JSON, XML, and queries
StringUtil@coreDelegates
String manipulation: slugify, camelCase, snakeCase, pluralize, etc.
➡ See Core Delegates for method references and examples.
ColdBox Delegates (@cbDelegates)
ColdBox-specific delegates available when your application runs inside ColdBox.
AppModes@cbDelegates
Check the current application mode (debug, development, production, testing)
Interceptor@cbDelegates
Announce and listen to ColdBox interception events
Locators@cbDelegates
Locate files and directories within the ColdBox application
Population@cbDelegates
Populate objects from the request collection, JSON, XML, or query
Rendering@cbDelegates
Render views, layouts, and external views
Routable@cbDelegates
Build links, routes, and access base URL helpers
Settings@cbDelegates
Read and write ColdBox and module settings
➡ See ColdBox Delegates for method references and examples.
Last updated
Was this helpful?