Hi AJ,

As you discovered you will want to use the default 'EventInvoker' when
defining your listeners.  If you simply omit the parameter, this is
the default, for example:
<listeners>
<listener name="myListener" type="components.path.to.myListener" />
</listeners>

When you do this, every call to that listener will get a reference to
the Mach-ii event object, and then you can set event arguments in your
function, in addition to the return value.  For example:

<event-handler event="myEvent" access="public">
  <notify listener="myListener" method="someMethod"
resultArg="myResult" />
</event-handler>

<cffunction name="someMethod" access="public" output="false"
returntype="string">
  <cfargument name="event" type="MachII.framework.Event"
required="true">

  <cfset event.setArg('myArgument1', 'value1') />
  <cfset event.setArg('myArgument2', 'value2') />

  <cfreturn 'valueforMyResult' />
</cffunction>

I hope that helps.
 -- Jason

On Apr 14, 11:14 am, AJ Ferrigno <[email protected]> wrote:
> Hi group - an admitted Mach-II newb here,
>
> I've come across something in my development that I'm not sure if it's
> a bug or a feature, so I wanted to see if I'm maybe doing it wrong.
>
> We have inherited a couple Mach-II applications where every listener
> is defined as type EventArgsInvoker. In the process of trying to
> improve our usage of Mach-II and separate code out as much as
> possible, I have found the need to set an event-arg parameter from one
> of the listeners, so it could be used by the XML after the call. It is
> basically the only way I know of returning more than one piece of
> information from the listener (the other piece is already being
> returned via the resultArg). However, I tried to do this and I quickly
> realized that EventArgsInvoker does not actually pass in the event
> object to the listener. That is specifically the job of the
> alternative EventInvoker.
>
> So my question is this: is it possible to set a new event-arg in a
> listener that is of type EventArgsInvoker? I cannot find a way to do
> this; the event variable only contains the name of the event itself,
> not the object information.
>
> If not, does anyone think it would be a problem to pass in the event
> object as well as all event-args to that type of listener? I have
> modified the framework on my local instance to do just this, and it
> seems to solve my problem. I'm just wondering if there is a specific
> reason for not passing in that event object (memory, speed, etc). I
> understand that the recommendation is to use EventInvoker instead of
> EventArgsInvoker, but it really isn't an option for our site to switch
> to that (at least in the short term), as everything is already coded
> using an argument approach.
>
> Another alternative, maybe we could define another type (or set) of
> invokers which could use a "resultStruct" idea. That way, I could
> return a struct from my listener, and the invoker would loop over that
> struct and set the appropriate values based on their names. But maybe
> that is fundamentally wrong, as a function should by definition only
> return one thing.
>
> Anyway, anyone have any thoughts?

-- 
To post to this group, send email to [email protected]
For more options and to unsubscribe, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en

SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/

Reply via email to