Hi Joe,

Just noticed that this bug still exists in svn
I've attached a diff of rev114 against my working copy in case its helps

Cheers, Chris

2008/7/30 Joe Rinehart <[EMAIL PROTECTED]>

>
> Hey Chris,
>
> Thanks for finding that - I'll try to get it into the BER this week!
>
> -Joe
>
> On Jul 29, 2008, at 10:42 AM, Chris Blackwell wrote:
>
> >
> > Hi Joe,
> >
> > Thanks for the reply, this has been driving me a bit crazy :)
> >
> > I've had a look at EventContext.cfc and i think the issue is with the
> > addResult() method, and the way it handles results with redirect=true.
> >
> > The addResult method loops over the eventhandler results for every
> > format, not just the current requestFormat.  So when it finds one that
> > matches, that has redirect=true it will immediately redirect to the
> > new event preventing the result for the current requestFormat from
> > ever being reached.
> >
> > I've modified my EventContent.addResult() to look like this
> >
> > <cffunction name="addResult" access="public" hint="Adds a result, by
> > name, to the result queue.">
> >       <cfargument name="resultName" type="string" hint="The name of the
> > result (e.g., ""formInvalid"" or the like) to add." />
> >
> >       <cfset var results = getResults() />
> >       <cfset var format = "" />
> >       <cfset var formatList = listappend(getValue("requestFormat", ""),
> > "cfNullKeyWorkaround") />
> >       <cfset var i = "" />
> >       <cfset var eh = getCurrentEventHandler() />
> >       <cfset var result = "" />
> >
> >       <cfset trace("Message Listener", "A named result
> > ""#arguments.resultName#"" has been added.") />
> >
> >       <cfloop list="#formatList#" index="format">
> >
> >               <cfif structkeyexists(eh.results, format) AND
> > structKeyExists(eh.results[format], arguments.resultName)>
> >                       <cfloop from="1" to="#arrayLen(eh.results[format]
> > [arguments.resultName])#" index="i">
> >                               <cfset result =
> eh.results[format][arguments.resultName][i] />
> >
> >                               <cfif result.redirect>
> >                                       <cfset this.trace("Result",
> "Explicit result redirecting to event
> > ""#result.event#""", "<result do=""#result.event#""
> > redirect=""true"" /
> >> ") />
> >                                       <cfset
> forward(eventName:result.event,
> > preserveState:result.preserveState, addToken:false,
> > append:result.append, anchor:result.anchor) />
> >                               </cfif>
> >                       </cfloop>
> >               </cfif>
> >
> >       </cfloop>
> >
> >       <cfset arrayAppend(variables._results, arguments.resultName) />
> > </cffunction>
> >
> >
> > I've replaced the outer loop over all formats with a loop over the
> > current requestFormat, and "cfNullKeyWorkaround" only (which i believe
> > is for results with no format specified).  This seems reasonable to
> > me, as I can't think why you would want alternate request format
> > results being fired on the current request.
> >
> > Hopefully that makes some sense, but feel free to point out the
> > obvious gotchas that i've missed :)
> >
> > Cheers, Chris
> >
> >
> >
> > On Jul 29, 2:26 pm, Joe Rinehart <[EMAIL PROTECTED]> wrote:
> >> This may be a bug in format-specific result handling, I'll look into
> >> it when I can.  If you'd like to help me verify, feel free to open up
> >> EventContext.cfc, jump down to the part where it's handling results,
> >> and if you could look into what's going on when it dequeues results
> >> it'd be handy - feel free to file any findings athttp://
> bugs.model-glue.com/jira
> >>
> >> Thanks,
> >>
> >> Joe
> >>
> >> On Jul 28, 2008, at 4:05 PM, Chris Blackwell wrote:
> >>
> >>
> >>
> >>> I'm trying to use a single event to handle updating a record, either
> >>> via traditional form submit or via ajax xhr.
> >>
> >>> this is my event handler
> >>
> >>>    <event-handler name="user.save"
> >>> type="model.event.SecuredEventHandler">
> >>>            <broadcasts>
> >>>                    <message name="updateUser" />
> >>>            </broadcasts>
> >>>            <results format="json">
> >>>                    <result name="User.ValidationError"
> >>> do="json.validationerror"
> >>> redirect="true" append="userid" />
> >>>            </results>
> >>>            <results format="html">
> >>>                    <result name="User.ValidationError"
> >>> do="user.edit" redirect="true"
> >>> append="userid" />
> >>>                    <result name="User.Saved" do="user.index"
> >>> redirect="true" />
> >>>            </results>
> >>>    </event-handler>
> >>
> >>> I'm submitting a user form, with requestFormat=json and my
> >>> controller
> >>> is correctly adding a User.ValidationError result, however its
> >>> running
> >>> the result for html and redirecting to user.edit  If i remove the
> >>> <results format="html"> block then my json result runs fine
> >>
> >>> I've used the format="json" attribute successfully for broadcasts
> >>> and
> >>> views, but this is the first attempt at using it with results, i'm
> >>> hoping it is supported ?
> >>
> >>> Chris
> >>
> >>
> > >
>
>
> >
>

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

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Attachment: EventContext.cfc.diff
Description: Binary data

Reply via email to