0

Mach-II, Event Chains, And You

MachII

(Let me preface this by saying the general concept is successful, but the actual reason I created this plugin has yet to be addressed...so it may or may not be the best solution for the problem at hand.)

We have decided that we want to assemble some user interface sections out of a few different events (Mach-II Events) but, throughout the process we may or may not want to do some event mapping to dynamically call events in that process.

 

Example:

We want to have an event that sets specific args (title, dimensions, data, whatever) that gets passed to another event that will assemble that info into a 'dumb' form layout, or form widget, etc. Now, the big deal here is that these dumb widgets are going to be used by any number of other events so they must be able to accept info from previous events, and decide whether or not to continue announcing other events to complete the request.

 

The hour long drive home yesterday got me thinking of a way to gracefully dictate that event flow, while still being very clear in the controller (the machii config xml) what was going to happen on that request. The EventChain plugin was born out of that brainstorming session.

The EventChainPlugin simply has a postEvent() process that looks for the existence of an event-arg named “EventChain” which is a comma delimited list of event names you would like to have run in that request. In the very first event that is run on the request, you build your chain and let the plugin do the rest.

        <event-handler name=”Event1”>

            <event-arg name=”EventChain” value=”event2,event3,event4,event5” />

            <!--

            do event stuff here

            --->

        </event-handler>

        <event-handler name=”Event2”>

            <!--

            do event stuff here

            --->

        </event-handler>

and so on...

(notice: only assign the arg in that initial event if you want to be able to use your other events wherever you want)

If you don't supply the EventChain arg, or it finishes its list of events, it just rests peacefully waiting for the next chain.


click here to download EventChainPlugin.cfc

tags:
MachII

Search