+1

Paul Marcotte had a somewhat related blog post.  He was discussing
redirection due to security (not being logged in for secured events), but
the question of redirecting in the controller (via event.forward()) vs the
MG.xml (via named results) was involved.

http://www.fancybread.com/blog/post.cfm/Model-Glue-Event-Security-Using-Broadcasts-and-Results

To quote/summarize what Paul had to say regarding that particular aspect of
it:

"In a previous application I chose to use event.forward() within my
controller to redirect the request to the login event. Although this works,
it is, in my opinion, better to use addResult and have Model Glue handle the
redirection. Although the xml is more verbose, I really like that the intent
of each event is clearly defined. Which provides a nice roadmap for any
other developers that may take over the project."

On Tue, Mar 16, 2010 at 5:03 AM, Dan Wilson <[email protected]> wrote:

> I prefer:
>
> <event-handler name="Form">
>     <broadcasts>
>         <message name="needFormBean" />
>     </broadcasts>
>     <views>
> <include name="primary" template="form.whatever.cfm">
> <value name="XE_handleForm" value="my.form-processor" />
>  </include>
>     </views>
> </event-handler>
>
> <event-handler name="doForm">
>     <broadcasts>
>         <message name="handleFormProcessing" />
>     </broadcasts>
>     <results>
>         <result name="failure" do="Form"  />
>         <result name="success" do="List" redirect="true" />
>         <result name="customresult" do="IfNeeded" redirect="true" />
>     </results>
> </event-handler>
>
>
>
>
>    1. Named results help autodocumentation and also help developers
>    understand the potential flow of the application without digging through
>    files
>    2. Having a separate form and form processing event keeps the logic a
>    little cleaner and allows for less coupled controllers to the views.
>    3. Using event.forward() means you either need to pass in the
>    destination event as an argument to the message (good practice), or a
>    developer must dig into the controller to find out the flow control (bad
>    practice)
>
>
>
>
> DW
>
>
> On Mon, Mar 15, 2010 at 11:35 PM, Matt Quackenbush 
> <[email protected]>wrote:
>
>> Consider the use case of form processing in MG3.  The request should be
>> redirected based upon the success or failure of the processing.
>>
>> Which of the following is your preferred method, and why?
>>
>> <!--- Scenario #1: Controller (pseudo-code) --->
>> <cffunction name="doSomething">
>>     <cfargument name="Event" />
>>
>>     <cfscript>
>>         if ( beans.myService.success() ) {
>>             forward("my.success-event");
>>         } else {
>>             forward("my.error-event");
>>         }
>>     </cfscript>
>> </cffunction>
>>
>>
>> <!--- Scenario #2: ModelGlue.xml --->
>> <event-handler name="my.form-processor">
>>     <broadcasts>
>>         <message name="handleFormProcessing" />
>>     </broadcasts>
>>     <results>
>>         <result name="formHasErrors" do="my.error-event" redirect="true"
>> />
>>         <result name="formProcessingSuccess" do="my.success-event"
>> redirect="true" />
>>     </results>
>> </event-handler>
>>
>> Thanks in advance.
>>
>> --
>> 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]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en
>



-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

-- 
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

Reply via email to