Controller bug with redirect?

26 views
Skip to first unread message

John Buhl

unread,
May 22, 2012, 3:26:07 PM5/22/12
to framework-one
Is this a bug or is it by design?

When I add variables to the rc scope in my controller I am expecting
the new values added to be available in the "after" function of the
controller. This works as expected unless I have a redirect in the
controller. The after function is still called with the redirect, but
the rc variables that show up are only the original ones passed in
from the page.

Example:

<cffunction name="thisWorks" >
<cfargument name="rc" type="struct" required="true" >
<cfset rc.somevar = "this shows up just fine">
</cffunction>

<cffunction name="thisDoesntWorks" >
<cfargument name="rc" type="struct" required="true" >
<cfset rc.somevar = "this doesn't show up">
<cfset variables.fw.redirect(action="main.somewhere",
preserve="all")>
</cffunction>

<cffunction name="after" >
<cfargument name="rc" type="struct" required="true" >
<cfdump var="#rc#">
</cffunction>

Sean Corfield

unread,
May 22, 2012, 3:46:30 PM5/22/12
to framew...@googlegroups.com
On Tue, May 22, 2012 at 12:26 PM, John Buhl <john...@gmail.com> wrote:
> When I add variables to the rc scope in my controller I am expecting
> the new values added to be available in the "after" function of the
> controller.  This works as expected unless I have a redirect in the
> controller.  The after function is still called with the redirect, but
> the rc variables that show up are only the original ones passed in
> from the page.

Are you *sure* the after() function is still called?

The redirect takes effect immediately and no further methods should be invoked.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

John Buhl

unread,
May 22, 2012, 3:54:50 PM5/22/12
to framew...@googlegroups.com
Ah, ok.  This make sense now.  This particular controller is being called in my setupRequest as well, so I was being fooled into thinking it was happening just after the redirect when it was actually occurring from the subsequent request.

John



Sean Corfield

unread,
May 22, 2012, 5:03:43 PM5/22/12
to framew...@googlegroups.com
On Tue, May 22, 2012 at 12:54 PM, John Buhl <john...@gmail.com> wrote:
> Ah, ok.  This make sense now.  This particular controller is being called in
> my setupRequest as well, so I was being fooled into thinking it was
> happening just after the redirect when it was actually occurring from the
> subsequent request.

And bear in mind that calling controller() in setupRequest() just
queues up the controller method to be executed as part of the
lifecycle (like calling service(), it doesn't directly execute the
method - it just tells FW/1 to execute it when it's good and ready to
do so).
Reply all
Reply to author
Forward
0 new messages