Dan,

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

--
Ezra

On Tue, May 26, 2009 at 7:19 AM, Dan Wilson <[email protected]> wrote:
> If you happen to be using MG 3, there are 2 methods on the event which might
> be of use.
> getInitialEventHandlerName()
> getEventHandlerName()
>
>
> The preference is to use getInitialEventHandlerName as it is more explicit
> in what it does and makes more sense when chaining events.
> getEventHandlerName() will return the same value, but could lead to
> confusion in complicated chained event scenarios.
>
> Are you using MG3? If so, would you please verify these methods do what you
> need them to?
>
> DW
>
>
>
>
> On Tue, May 26, 2009 at 10:14 AM, salvatore fusto <[email protected]>
> wrote:
>>
>> all together now!
>> seriously, this is fine, thank you all.
>> salvatore
>>
>> On 26 Mag, 15:59, Dan Wilson <[email protected]> wrote:
>> > It really isn't a hack, it is just a nested function.
>> > The value of the event is inside of the Event object, so we use
>> > arguments.event.getValue() to return it.
>> >
>> > Since ModelGlue allows any key name to be used for the event, you can
>> > change
>> > event=Some.Event, to x= Some.Event, or even whatever= Some.Event. The
>> > price
>> > for this abstraction is you gotta dynamically determine which key you
>> > are
>> > using... by this function: arguments.event.getValue("eventValue"). So
>> > put
>> > all together:
>> >
>> > arguments.event.getValue(arguments.event.getValue("eventValue"))
>> >
>> > Now you can get the name of the event, however you choose to refer to
>> > the
>> > event. Hack-free, Future Proof. Compact, Yet Stylish, no?
>> >
>> > DW
>> >
>> > On Tue, May 26, 2009 at 9:48 AM, salvatore fusto
>> > <[email protected]>wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Yup, this works, but is so strange (it seems an hack) so can yoy
>> > > expalin me?
>> > > thanks
>> > > salvatore
>> >
>> > > On 26 Mag, 14:41, Tom McNeer <[email protected]> wrote:
>> > > > Salvatore,
>> >
>> > > > On Tue, May 26, 2009 at 3:20 AM, salvatore fusto
>> > > > <[email protected]
>> > > >wrote:
>> >
>> > > > > in mg1 i used to extract the name of the triggered event with a
>> > > > > trivial event.getEventHandlerName() in the onRequestStart of a
>> > > > > controller: how can i do the same in mg3?
>> >
>> > > > Try:
>> >
>> > > > arguments.event.getValue(arguments.event.getValue("eventValue"))
>> >
>> > > > --
>> > > > Thanks,
>> >
>> > > > Tom
>> >
>> > > > Tom McNeer
>> > > > MediumCoolhttp://www.mediumcool.com
>> > > > 1735 Johnson Road NE
>> > > > Atlanta, GA 30306
>> > > > 404.589.0560
>> >
>> > --
>> > “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- Nascondi testo citato
>> >
>> > - Mostra testo citato -
>>
>
>
>
> --
> “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
>
> >
>

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

Reply via email to