I put up a FAQ article on this topic here: http://docs.model-glue.com/wiki/FAQs/WhyDoesMyControllerVariableNotGetSetAfterAddResultIsCalled
Feel free to update it as you see fit to help others understand the issue. DW On Fri, Feb 12, 2010 at 9:23 AM, steveG <[email protected]> wrote: > That makes sense, I was under the mistaken impression that the > function would have to complete prior to notifying the handler of the > result. > > Thanks for the help! > Steve > > On Feb 12, 9:10 am, Dan Wilson <[email protected]> wrote: > > If your result redirects, then yes. > > > > From the docs here: > http://docs.model-glue.com/wiki/ReferenceMaterials/ModelGlueXmlRefere... > > > > <result> ¶< > http://docs.model-glue.com/wiki/ReferenceMaterials/ModelGlueXmlRefere...> > > > > Defines an additional event-handler to execute as part of the current > > request. Can use the NAME attribute to determine whether or not a > certain > > result should be executed, and the REDIRECT attribute to abort the > current > > request and redirect to a different event handler. > > Attributes ¶< > http://docs.model-glue.com/wiki/ReferenceMaterials/ModelGlueXmlRefere...> > > > > 1. Do (Required) - The NAME attribute of an event handler to add to > this > > request. > > 2. Name (Optional) - If not set *or set to an empty string*, the event > > handler declared in the DO attribute will always be added to the > request. > > If not empty, the event handler declared will only execute if a > function in > > a Controller CFC uses the addResult() method of the Event API to add a > > result with the value of the NAME attribute. > > 3. Redirect (Optional, default = "false") - If true, a redirect will > > immediately redirect the entire request to the event handler declared > in the > > DO attribute. All state value will be maintained if session is > enabled. > > 4. Append (Optional, default = "") - Used to define a list of value > > names (from the viewstate) that should be appended to the URL. > > > > Example: If APPEND is set to articleId and DO is set to article, the > > redirect URL would be index.cfm?event=article&articleId=[value of > > articleId]. > > > > *Advanced, rarely used attributes:* > > > > 5. PreserveState (Optional, default = "true") - If set to false and > > REDIRECT is set to true, then all state values will removed before > > redirecting to the event handler declared in the DO attribute. If > using this > > be sure that session management is enabled. > > 6. Reset (Optional, default = "false") - If set to true, any > previously > > declared results of the same name will be erased. *This is only > useful > > for redefining results added by scaffolds.* > > > > Child Tags ¶< > http://docs.model-glue.com/wiki/ReferenceMaterials/ModelGlueXmlRefere...> > > > > None > > > > > > > > On Fri, Feb 12, 2010 at 9:05 AM, steveG <[email protected]> wrote: > > > I have a controller function with odd behavior. > > > > > Calling this function sets the session variable and passes the > > > loggedIn result back to the event handler: > > > > > <cffunction name="authenticate" access="public" returnType="void" > > > output="false"> > > > <cfargument name="event" type="any"> > > > <!--- some logic here ---> > > > <cfset session.loggedIn = true /> > > > <cfset arguments.event.addResult("loggedIn") /> > > > </cffunction> > > > > > However if I set the session variable after the addResult() call, the > > > session variable never gets set: > > > > > <cffunction name="authenticate" access="public" returnType="void" > > > output="false"> > > > <cfargument name="event" type="any"> > > > <!--- some logic here ---> > > > <cfset arguments.event.addResult("loggedIn") /> > > > <cfset session.loggedIn = true /> <!--- session var doesn't get > > > set ---> > > > </cffunction> > > > > > Is this the expected behavior? If a result is being passed back to the > > > handler should it always be the last item in the controller function? > > > > > Thanks, > > > Steve > > > > > -- > > > Model-Glue Sites: > > > Home Page:http://www.model-glue.com > > > Documentation:http://docs.model-glue.com > > > Bug Tracker:http://bugs.model-glue.com > > > Blog:http://www.model-glue.com/blog > > > > > You received this message because you are subscribed to the Google > > > Groups "model-glue" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected]<model-glue%[email protected]> > <model-glue%[email protected]<model-glue%[email protected]> > > > > > For more options, visit this group at > > >http://groups.google.com/group/model-glue?hl=en > > > > -- > > “Come to the edge, he said. They said: We are afraid. Come to the edge, > he > > said. They came. He pushed them and they flew.” > > > > Guillaume Apollinaire quotes > > -- > Model-Glue Sites: > Home Page: http://www.model-glue.com > Documentation: http://docs.model-glue.com > Bug Tracker: http://bugs.model-glue.com > Blog: http://www.model-glue.com/blog > > You received this message because you are subscribed to the Google > Groups "model-glue" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<model-glue%[email protected]> > For more options, visit this group at > http://groups.google.com/group/model-glue?hl=en > -- “Come to the edge, he said. They said: We are afraid. Come to the edge, he said. They came. He pushed them and they flew.” Guillaume Apollinaire quotes -- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
