redirection from interceptor with persist

I seem to recall reading something in the docs or one of the blogs
about this, but cannot re-locate it. I have a preEvent interceptor in
which I test the current handler, and if certain conditions are met,
redirect. However, the info I persist does not seem to exist when the
handler:action receives it. If you can point me to resources or tell
me what it is I need to do, I would appreciate it!


Hi Bill. Check out this URL:

Thanks, Doug. Perhaps I was not clear. I do know how to redirect and persist. I have done that in a number of situations (redirecting either to another action in the same handler or to a different handler:action). No, my problem is that when I redirect from an interceptor (preEvent), the persisted value does not exist once the request reaches the handler:action to which I redirected. For example:

<cfset var rc = event.getCollection()>

<cfset var currentEventHandler = event.getCurrentHandler()>

<cfif currentEventHandler eq ‘CustomerHandler’ >

<cfif validcustomer neq 1>

<cfset setNextEvent(event=customer.list, persist=‘myMessage’) />

When I try to access rc.myMessage in customer.list, I get an error stating that myMessage does not exist in rc. Maybe what I am trying to do is impossible and that is what I recall reading, though it feels like I read where this cannot be done, but there is a work around, or something similar anyway.

Any ideas?

&lt;cfset setNextEvent\(event=customer\.list, persist=&#39;myMessage&#39;\) /&gt;

As you seem to know, setNextEvent does a cflocation (via response 302
Moved Temporarily) to the next event. "Persist" parameter should put
the rc.myMessage in the Flash scope to be automatically placed in the
next RC.

First off, make 'customer.list' a string (surrounded in quotes) ...
but per your example it sounds like you're getting to the next event.
If you are going to customer.list directly (not thru the 302 redirect)
then obviously the rc.myMessage won't exist. Watch your test case
with some kind of http introspection (like Charles Proxy or Firebug)
to assure you are getting the 302 on the first call then are getting
another HTTP response from the next event that you redirected to.

Second, where are you putting Flash scope? That is the Coldbox
mechanism that is moving the Persist param from orig request to the
relocated one. Look in Coldbox.cfc for where you have
"flashURLPersistScope" set to. I use "session". Make sure you are
enabling that scope in your application settings.

I just did a test of setNextEvent() w/ a persist param in 3.0 M6 from
a Interceptor PreProcess method and got the persisted data just fine:
  <cffunction name="preProcess" access="public" returntype="void"
output="false" >
    <cfargument name="event" required="true"
type="coldbox.system.web.context.RequestContext" hint="The event
    <cfargument name="interceptData" required="true" type="struct"
hint="interceptData of intercepted info.">

    <cfif event.getCurrentAction() neq "list">
    <cfset event.getCollection().test = 'this is a test'>
    <cfset setNextEvent( event='user/list', persist="test")>

User/list dumped:
test = this is a test

It's working now, though not exactly sure why. I did have customer.list surrounded in single quotes, though, for some reason that is not reflected below. I surrounded everything in double quotes, reinited the framework and there is myMessage! I am thinking I failed to reinit the framework when testing previously (I wasn't running a unit test, to my shame). Thanks!

Use the flash scope instead and try again