[CB 4.3] Post action interceptor not firing when setNextEvent() is called

I have a basic handler in a module with a method “updateBOM”. I have both “preUpdateBOM” and “postUpdateBOM” methods. The pre interceptor fires but the post does not.

The main updateBOM method ends with a setNextEvent(). If I remove the setNextEvent(), the post handler will fire just fine.

To test I also added a generic postHandler() method that just logged when fired and it also would not fire when there was a setNextEvent() in the main method.

I tried specifically setting postProcessExempt to false (just in case, even though it supposedly defaults to that) bu that didn’t help.

I’m stumped.

Running: ColdBox SEEK 4.3.0+188 Nehemiah

setNextEvent() is an immediate redirect (cflocation), so any post handler methods will not fire. I’m not sure if there’s really a work around for that.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks Brad.

But, if that’s true then I’m curious why setNextEvent would then have an option to specifically disable post processing? (the “postProcessExempt” flag that defaults to “false”)

You’re thinking of runEvent(). setNextEvent() has no such argument. Check the API docs.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Nope… it’s a documented arg for setNextEvent():

public any setNextEvent([any event=’[runtime expression]’], [any queryString=’’], [boolean addToken=‘false’], [any persist=’’], [struct persistStruct=’[runtime expression]’], [any baseURL=’’], [boolean postProcessExempt=‘false’], [any URL], [any URI], [numeric statusCode=‘0’])

postProcessExempt - Do not fire the postProcess interceptors, by default it does

I’d link directly to it but the quick docs are all frame based.

I figured out how to get the link!

http://apidocs.ortussolutions.com/coldbox/4.3.0/coldbox/system/web/Controller.html#setNextEvent()

Whoa, you’re right. That’s really weird because I pulled open the code and looked before sending my last message, but I must have opened up the file from an old version of ColdBox or something!

So, looking at the code (again…), it looks like it it’s used here:

// Post Processors
if( NOT arguments.postProcessExempt ){
services.interceptorService.processState(“postProcess”);
}

But that only controls postProcess interceptors, not the implicit methods in your actual handler. You can put in a ticket for ColdBox to run “post{Action}” and “postHander” methods before calling setNextEvent(). And in the meantime, you can convert your postHandler method to an interceptor with an event Pattern that only listens to that handler.

function postProcess( … ) eventPattern=’^handlerName.’ {
// Your code here
}

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks Brad! I also dug through that code before posting to make sure I wasn’t losing my mind. I already created a workaround so we’re good for now. I will add a ticket though.