On Mon, 09 Nov 2009 16:07:12 +0000, "Phil Ewington - iModel Ltd."
<phil.ewing
...@i-model.co.uk> wrote:
> Totally new to Mach II, building first app and got a question about the
> events.
Welcome to Mach-II!
> I have an event to create a registration and want to conditionally call
> another method in my listener if the registration is based upon a
> referral.
If the other method in your listener is never called independently, you
probably want this other method in your service, not in your listener.
> My thinking is...
> 1) I could write the conditional call within my service layer. Not happy
> about this as the functionality gets 'hidden' away from other developers.
I would conditionally make a call to your service layer from within your
listener. At least that's what seems right to me based on what you're
saying thus far.
> 2) I could use a filter and have different event handlers to handle the
> result. I have lots of these types of conditions in my events and would
> rather not have a huge collection of event-handlers unless of course I
> have no option/no better way of doing it.
That sounds unnecessarily complicated.
I may not have the full picture, but in your listener method I'd probably
do:
<cfif isReferral> <!--- or however you determine if it's a referral --->
<cfset getMyService().doReferralStuff(event.getArg("arg1"),
event.getArg("arg2")) />
</cfif>
That way you can pass whatever event arguments you need to as part of the
referral bit.
Definitely let me know if I'm missing a piece of the puzzle.
--
Matthew Woodward
m...@mattwoodward.com
http://mpwoodward.posterous.com
identi.ca/Twitter: @mpwoodward
Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html