Model-Glue:Unity "ActionPacks"

One critique I've heard about Model-Glue is that there's no easy way to create "modules" of functionality that can be "dropped in" to existing applications. I mean, wouldn't it be nice to write a forum app, and then just say "add this to my Model-Glue application?"

[Read more on Joe Rinehart's blog]

Well, there's a new tag in Model-Glue:Unity that allows just this: <include> as a child of <modelglue>. I've resisted it for a while, but I think that, when used properly, it could be a very nice addition to the framework.

This addition means that any ModelGlue.xml file can other ModelGlue.xml-format files, and that the "child" files can declare their own <controllers> and <event-handlers>.

Additionally, the Model-Glue XML "fragments" can use the <setting> tag to declare additional XML files to load into ColdSpring as well as additional directories to use as view mappings.


This means that I could have a Wiki.xml "fragment" file declaring everything needed for a wiki:

<!-- Add the wiki /views dir to the viewmappings -->
<setting name="viewMappings" setting="/mgwiki/views" />

<controller name="wikiController" type="mgwiki.WikiController">
<message-listener message="" function="getPage" />
<!--- other listeners... --->

<event-handler name="wiki.displayPage">
<message name="" />
<include name="body" template="dspWikiPage.cfm" />
<result do="view.template" />

<!--- More event handlers... --->

Then, if I wanted to add Wiki functionality to any other Model-Glue application, I could change its ModelGlue.xml file to include the Wiki fragment:

<include template="/mgwiki/config/Wiki.xml" />

<!--- Application stuff...--->

Dangers of Includes

Doing this isn't without a danger: it's quite possible that an include would overwrite an existing event handler or controller. That's the reason I prefixed everything with "wiki" :).


I'm planning on releasing a few fragments in the publuc "2.0" Unity release that I'll be calling "ActionPacks." One will provide an easy to use, configurable e-mail service. Another will provide role-based and row-level security, user profile management, and user administration interfaces.

Because these "ActionPacks" don't require any change to the framework, and are really just Model-Glue XML fragments, anyone is free to contribute their own to the Model-Glue community. If anyone's interested in developing them, I'd be happy to help out where I can, and for select Action Packs (like maybe a forums app!), adding them to the Model-Glue distro itself.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
OK... is this technology still possible with 3.0? It seems like modules would be a good thing to me and you can include me in the group of developers who want to build modules. :)
# Posted By John Farrar | 6/23/09 9:18 AM
© 2019 Joe Rinehart
BlogCFC was created by Raymond Camden. This blog is running version