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]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to