As alluded to yesterday, I'm posting this as a distillation of just the results of my investigations, without all the blather as to how I arrived at these results. This'll make it easier for people to see just the code, should they want to.
The full narrative is in yesterday's article. There is no additional material in this that was not covered y/day, so there's no need to read it. It's here just for reference.
Baseline file system
D:\webapps\helloWorld\www <--- Apache doc root D:\webapps\helloWorld <--- ColdFusion root D:\webapps\helloWorld\com\daccf\helloworld <--- my app code will be in here D:\webapps\helloWorld\org\coldbox\coldbox_3.5.2 <--- this will be my /coldbx mapping location D:\webapps\helloWorld\org\coldbox
\coldbox_3.5.2
\system <--- ColdBox files
In the Apache doc root
// Application.cfc
component extends="com.daccf.helloworld.Application" {
}
<!--- index.cfm --->
<!--- [THE FILE EXISTS, BUT IS EMPTY] --->
In the application directory
Config
// /com/daccf/helloworld/Application.cfc
component {
variables.thisDir = getDirectoryFromPath(getCurrentTemplatePath());
this.name = "HelloWorld";
this.sessionManagement = true; // It seems Coldbox requires this to be on, even thoough I'm not going to be using sessions :-(
this.mappings = {
"/" = variables.thisDir,
"/coldbox" = expandPath("/org/coldbox/coldbox_3.5.2")
};
// reqd COLDBOX settings
COLDBOX_APP_ROOT_PATH = variables.thisDir; // COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP
COLDBOX_APP_MAPPING = ""; // The web server mapping to this application. Used for remote purposes or static purposes
COLDBOX_CONFIG_FILE = ""; //COLDBOX PROPERTIES
COLDBOX_APP_KEY = ""; //COLDBOX APPLICATION KEY OVERRIDE
public boolean function onApplicationStart(){
//Load ColdBox
application.cbBootstrap = createObject("coldbox.system.Coldbox").init(COLDBOX_CONFIG_FILE,COLDBOX_APP_ROOT_PATH,COLDBOX_APP_KEY,COLDBOX_APP_MAPPING);
application.cbBootstrap.loadColdbox();
return true;
}
public boolean function onRequestStart(required string targetPage){
application.cbBootstrap.onRequestStart(arguments.targetPage);
return true;
}
}
// /com/daccf/helloworld/config/Coldbox.cfc
component{
public void function configure(){
variables.coldbox = {
appName = application.applicationName
};
}
}
Handlers / controllers
// /com/daccf/helloworld/handlers/main.cfc
component {
public string function index(event,rc,prc){
prc.message = getModel("models.Message").get();
}
}
Model
// /com/daccf/helloworld/models/Message.cfc
component {
public string function get(){
return "Hello World";
}
}
View
<!---/com/daccf/helloworld/views/main/index.cfm--->
<cfoutput>#prc.message#</cfoutput>
That's it. Cheers.
--
Adam