Ticket #391 (closed enhancement: fixed)

Opened 16 years ago

Last modified 16 years ago

getInitialEventHandlerName() and getEventHandlerName() do not work in onRequestStart

Reported by: mineerjr@… Owned by: cfgrok
Priority: normal Milestone: 3.1 Maintenance Beta
Version: 3.1.185 Severity: normal
Keywords: Cc:

Description

Here are some details as posted to the group by Ezra:

I'm afraid that in MG 3 these methods both fail when called from an onRequestStart message listener function. I ran into this when testing out the upgrade of an MG 2 application for the documentation effort, and I evidently neglected to copy you on the message to the docs list where I detailed the issues I ran into -- here is the relevant portion:

The application was referencing the name of the currently-executing event by calling arguments.event.getEventHandlerName() in the onRequestStart event handler. Although this may not have been the best approach, it worked fine under Unity, but throws "You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members." in Gesture. I should note that this method appears to work as expected when called in the context of the actual executing event, it was only failing when invoked in the onRequestStart handler.

After investigating a little bit, I discovered that getEventHandlerName() internally calls getInitialEventHandler().name, but if it is called in onRequestStart, getInitialEventHandler() returns an empty string.

This appears to be an intentional change, as the private property returned (variables._initialEvent) is being set inside a boolean test against variables._readyForExecution, which in turn is set by the prepareForInvocation() method, and there is a comment immediately above the call to that method (in /ModelGlue/gesture/eventrequest/phase/Invocation.cfc) that reads: "Prepare for invocation _after_ queuing onRequestStart".

I was able to work around this by changing arguments.event.getEventHandlerName() to arguments.event.getValue(event.getValue("eventValue")). As a side note, I see that there is presently a minor issue logged at bugs.model-glue.com requesting a convenience method for this.

The ticket I referenced is one that was ported over from JIRA:

http://docs.model-glue.com/ticket/333

Change History

Changed 16 years ago by cfgrok

  • owner set to cfgrok
  • status changed from new to assigned

Changed 16 years ago by cfgrok

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in revision 255

Modified the getInitialEventHandler() method in EventContext? to correctly return the event name regardless of whether the initial event handler object has been created

Note: See TracTickets for help on using tickets.