Interceptor and the request context

So trying my hand at this for the first time without having copied someone elses code and feeling a little lost…Here is my basic interceptor…just for fun, I’m mimicking the appmapping variable…please just go with it, this is a learning experience.

component extends=“coldbox.system.Interceptor” {
void function configure(){}

void function afterConfigurationLoad(event,struct interceptData){
event.setValue(“siteroot”, getSetting(“AppMapping”));
if (getSetting(‘AppMapping’) EQ “”) {
event.setValue(“siteroot”, ‘/’);

That seems to run (I get no errors and some earlier debug code launched properly. My AppMapping variable SHOULD be nothing as I am working on a root site, not a directory so “/” is what I want. At some point in a much earlier discussion, it was suggested that if the appmapping is nothing I might want to set another variable to “/” so that I can easily build include strings without worrying about a leading “/” to indicate from the root.

So, as I say, this seems to run correctly. With this code, in a layout, I would expect to be able to output #rc.getValue(“siteroot”)# and get back “/”, in this example…but instead I get an error in my layout code saying the getValue method was not found in rc. I thought layouts and views “magically” received the “rc” scope (which as I understand, correct me if not, would be equivalent to event.getCollection())…but I tried created my own rc variable that way as well as event.getValue() and that does not work either saying, “value not found”…which suggests that rc is not automatically scoped AND that event.getValue() is the proper way to get the value I have set, but it looks as though the value is not correctly being set to anything (and even if some of that interceptor logic were garbage, the default initial value should be set to whatever appmapping is set to (which is ‘’).

I have been through and through the request context documentation and though I was following everything, I’ve been through the interceptor documentation and thought I was following that correctly and I read through the group notes on layouts and using rc/prc from the event and thought I followed that advice…but if I dump the rc and prc…in fact “siteroot” does not exist…so the error makes sense…but why?

Confused Mike of Addled Brain

Hi Mike,

I think you just need to do RC.siteroot. Getvalue is a method of the event not of the RC. I, of course, could be wrong, but that’s what I found to be true.

Kevin Anderson
Cell: 719.930.2599

good though…and I find documentation to support it…but unfortunately I think the problem that still seems to exist is that siteroot is not defined…I must be setting the value incorrectly in some way but I get no errors to suggest a course of action.