After my last post on custom event types in Model-Glue 3, the reaction was pretty much universal. Nice - but why can't we define these guys in XML?
As of about an hour or so ago, Joe checked into the MG3 Subversion repo an update that now allows you to do custom event types in XML, and frankly, it kicks butt. To define a custom event type, you create a new section of your ModelGlue.xml file named event-types. Here is an example:
1 <event-types>
2 <event-type name="templatedPage">
3 <after>
4 <results>
5 <result do="template.main" />
6 </results>
7 </after>
8 </event-type>
9 </event-types>
In general these follow the same formats as events, but they are separated into a before and after section. You would put broadcasts in the before block. Here is an example Joe created showing a security custom event type:
2 <event-type name="templatedPage">
3 <after>
4 <results>
5 <result do="template.main" />
6 </results>
7 </after>
8 </event-type>
9 </event-types>
1 <event-type name="securedPage">
2 <before>
3 <broadcasts>
4 <message name="doSecurityCheck" />
5 </broadcasts>
6 </before>
7 </event-type>
Using the custom event type hasn't changed. You simply provide the name:
2 <before>
3 <broadcasts>
4 <message name="doSecurityCheck" />
5 </broadcasts>
6 </before>
7 </event-type>
1 <event-handler name="page.index" type="templatedPage">
And of course you can use multiple custom event types:
1 <event-handler name="page.index" type="securedPage,templatedPage">
Can I get an "Amen" from the Model-Glue crowd?? (Thanks Joe!)
Comment 1 written by Dan Wilson on 11 June 2008, at 1:00 PM
That looks HOT!
I'm updating from SVN as we speak!
DW
Comment 2 written by Allen on 11 June 2008, at 5:42 PM
Comment 3 written by Raymond Camden on 11 June 2008, at 8:40 PM
Comment 4 written by Chris H on 12 June 2008, at 2:44 AM
Comment 5 written by Sameer Gupta on 12 June 2008, at 7:43 AM
Comment 6 written by Jeremy Prevost on 12 June 2008, at 12:41 PM
[Add Comment] [Subscribe to Comments]