page abort interceptor question

Fine folk,
  i'd like to set something up in my coldbox app where, if there's a
request collection variable named "abortrequest" present, that the
request will abort and will show the debug panel.

  I'd prefer not to add anything at all into my handler events (i.e.
no "if (event.valueExists("abortrequest") then abort) but instead
would like to have this happen at some interception point. Can you

  Basically, my current problem seems to be that if an event does
setNextEvent("whatever.whatever") then that automatically redirects.
Is there a way to somehow kill the nextEvent stuff in an interceptor?



You can use interceptor point preEvent and check if the url var match
or does not match a event.

Why do you want this actually? Why do you want to abort the request?


  On form submits, I often want to see the processing page... see all
the queries that happen in the event, see the request collection that
came in the form post, etc. So I have a checkbox on each form that,
when clicked, passes the abortrequest flag. Then, on the processing
side, i want the events to be sensitive to that such that if it's
present, the redirect is not fired and I just get the debug panel.

  So I can't use the preEvent function because I want to see
evertyhing at the end of the event, not at the beginning.

Make sense?


OK, so, I can use postHandler. that's cool.

and i see event.NoRender(), too. So... problem solved.


And line debugging is not an option for you?

locally, sure. but not in other environments, and this kind of ability
is particularly useful when debugging problems in production
environments where I sure as hell ain't gonna go in and comment out
code. In addition, I find that the debug output, listing all the
queries that run, etc, gives a nice big picture of the overall view of
the request that was just processed.

  I chatted with Luis about this and he suggested injecting a custom
udf to handle my logic. Here's what I ended up with and, so far, it's
working nicely.

first, in my layout file, i have this:

<script type="text/javascript">
      //for every form, if debug is on, add the abort checkbox
      <cfif controller.getDebuggerService().getDebugMode()>
      $("form").append("<input type='checkbox' name='abortredirect'
value='1'> Abort redirect?");

Then, in the handler, i have this:

  <cffunction name="preHandler">
    <cfargument name="Event" type="any" required="true"/>
    <cfif event.ValueExists("abortredirect")>
      <cfset variables.setNextEvent = cancelRedirects>
      <cfset event.setView('cancelredirect')>
  <cffunction name="cancelRedirects" access="public">

The bottom line for all this is that, with debug mode on, every form
will get a checkbox for cancelling redirects, and every event will
have redirects canceled if that checkbox is checked, without any
coding at all inside the events themselves. In addition, should I
desire, I can add whatever other useful hooey I want to inside the
cancelredirect view.

Thanks, Luis, for the mixin suggestion. I'm not sure if this is what
you had in mind, but it's where my mind went right away.


That looks Amazing Marc!! Nice decoupling!!

even nicer decoupling would be to figure out a way to hook this into
the new coldbox sidebar, which looks very cool. Will the sidebar
provide any plugin functionality? just curious is all.



The sidebar is actually an interceptor using the new output buffer. So you can configure as many properties as you like in it. Here is a sneak peek at the guide: