This Looks Like a Job for EventDuck!

So if you've worked with some other frameworks and you're curious about the onTap framework, it occurs to me that there's a reasonably simple way to convert your views to use the onTap framework without removing any of the references they make to the "event" object, even though the onTap framework doesn't have one and generally uses the "attributes" scope like older versions of Fusebox.

Just download the enclosure in this blog and extract it to the root of your onTap framework application (apologies to anyone who tried to download it before, I didn't realize you wouldn't be able to download a .cfc as an enclosure)

The .cfm in the archive will execute prior to your "event-handler" code (which is placed in /_local/) for each event and instantiate the duck, creating a substitute for the event object of your favorite framework.

I think this should work for views ported from ColdBox, Fusebox or Mach-II. Model-Glue might be a bit more involved with the viewState object, but the principal should be the same. The only reason this might break in any of your views is if either I didn't include an event method you use frequently in your views* or you've got a view template that calls methods on another CFC and those methods are strict-typed, expecting the "event" object to be of type "ColdBox.system.event" or the like instead of having an argument type of "any". But then in theory there shouldn't be a lot of method calls in your view templates anyway. ;) Still, it's another good reason to duck type.

* do people use param in their views? add a comment or drop me a note and I'll add any methods you use if I can simulate them

Related Blog Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress