Overriding the event using preEvent

I am in need to change the event for a given module, the idea is that when the pre-event is called the event is changed to a given module. I have tried both event.setNextEvent() but this doesn’t exists in the event for some reason. I also tried event.overrideevent() but it still runs the old event for some reason.

Anyone have any clues or ideas on the right way?

Ok as this is critical to something that I am writing at the moment, I decided to get into ColdBox and make some changes. However there could be a better way.

In Controller.cfc I founf the runEvent and modified the code after the interceptor announcement, to then reload the handler if the event has changed, as below.

Now the problem here is that in a preEvent a new handler with the preXXXX will not be run, that could mean some serious work arounds for developers if the handler is a requirement for the preHandler to run.

Not to mention that there is a caveat that one could easily, end up in a constant loop, if they where to continue overriding the event back to another and back again.

But for now I have modified the code below, so that I could use the interception point preEvent to change based on certain information. For the application this was going into, this appeared the only viable solution to achieve this.

// PREEVENT Interceptor
services.interceptorService.processState(“preEvent”,iData);

// Verify if event was overriden
if( arguments.default and arguments.event NEQ oRequestContext.getCurrentEvent() ){
// Validate the overriden event
ehBean = services.handlerService.getRegisteredHandler(oRequestContext.getCurrentEvent());
// Get new handler to follow execution
oHandler = services.handlerService.getHandler(ehBean,oRequestContext);
}