Force end slash for buildLink() using requestContextDecorator


I’m trying something easy to learn the RequestDecorator.
I’m trying to simply force the end slash when using buildLink.

The code works correctly, but the URL generated is missing the base when using the decorator.

I did some debugging and :
Using the buildLink normaly, the SESBaseURL has a value and gives me the proper URL for my project.
When implementing the buildLink for the decorator, using the same parameters, the sesbaseURL is empty for the context.

Any idea what might be causing this ?
Using coldbox 6.5.2
My decorator :

component extends="coldbox.system.web.context.RequestContextDecorator"{

  function configure(){
    return this;

  string function buildLink(
    boolean translate = true,
    boolean ssl,
  ){ = getRequestContext().buildLink(argumentCollection=arguments);
    return & (right(,1) NEQ "/" ? "/" : "" );


Your call to getRequestContext() is creating a new context since the decorator is not a child of the main context.

Try retrieving it with:

Thank you ! That was indeed the part I was missing, I tried but missed the getRequestService() to call from the controller.

I feel that calling the buildLink from the existing controller is making an infinite loop (goes back to the decorator and so on). How would you approach this ?

Hmm… I can see how that could happen, because the decorator appends and overwrites the existing methods, so you can’t call the super scope.

You may just need to copy the contents of the buildLink method in RequestContext.cfc and then attempt to do your slash appending after that.

1 Like