Model-Glue 3 - The New Frakin' Awesomeness

This post is more than 2 years old.

Before I get started - you can download the Alpha now available.

My notes from Joe's Model-Glue 3 presentation at cfObjective. Please pardon the bad writing here and some text are direct quotes without me using quotes (so basically, all copyright Joe).

Why is MG 3 being built? Joe had no plans on going past version 1. He was 'away' from CF for a while, came back, and realized some rough spots he wanted to improve on in the framework. The community has evolved, and this is impacting the development of MG. Awesome slide of the MG timeline stating that the old days were the "Fuseaic Era". (Fusebox Era) Next is the "Helmsian Period". (Mach II Era) And then MG began. (Ok, I'm really shortening up what was a good story. Sorry, can't type everything Joe is saying.) MG1 came out around the same time as some important (other) frameworks like ColdSpring, Transfer, Reactor. And eventually we grow into MG2. However, since there was more to MG2, this led to some confusion.

MG3 - code named Gesture - return to simplicity. "Back to basics" "It's goal is to provide the easiest workflow possible w/o sacrificing the benefits of adding Implicit Invocation."

MG3 is a feature release - ie, new features hoping to make your life easier. No giant changes to the way things are done by you - although a good bit of the code for MG itself is being redone.

All new features are aimed at productivity.

dsp is gone from the skeleton views - not the MG cared, but it's gone.

ViewState is gone - it's just Event now (woohoo!!!).

"ActionPacks" are coming. Like basic user management/user/group/event security action pack will ship with Alpha.

New features

  1. The ability to auto-generate code via the URL. So you can hit, and MG can create the xml/controller/model/view code for you. Uses a "Controller.Action" approach. FYI, this is something you can turn off, and will be (probably) disabled by default. You can enter the URL of an event that doesn't exist and get a wealth of free code. Example:

Run ant task to make new MG app.
Turn on the feature.
Type index.cfm?event=user.login
Edit userController.login() to make it real.
Edit view to make a form.
And you are done! (with no xml editing)
Oh, but wait - theres more - it will (eventually) also make unit tests for it.

Event Types

When you have 100 events, and 95 of them use a site wide template, you have 95 repeated lines of XML. This stinks. So what we need our Event Templates. You can create CFCs to extend EventHandler. You can make a login required event. You can do stuff before and after the event that uses the template is run. Security, layout, etc. In the XML, you just specify the type fgor the event.

<event-handler name="foo" type="events.TemplatedEvent">

This ties to code generation as well - if you use "type" in the URL when generating code, the new events will use that event type.


There ya go - it's supported. You can add listeners:

<message-listener message="onApplicationStart(SessionStart/SessionEnd" function=".." />

URL Manager

SES urls supported out of the box. You can build things the way you want. New ways to build URls:

<a href="#event.linkTo("user.profile","userid,profileid")>

Can result in either of these, up to you:

index.cfm?event=userid=x&profileid=3<br> OR index.cfm/userid/2/profileid/42


Have you used UDFs in a MG app? It's a pain. You have to include them into a view, and doesn't help the controller. You can now drop a library of UDFs and drop it into the helpers folder. Then you can access ALL the udfs via the helpers scope in controllers and views. (Love this.)


You can also drop an entire CFC into the folder and it acts the same way.

Bean "injection"

No more need to write setters for bean injection.

<cfcomponent beans="sameDAO" />

This code in your controller will then load the DAO into the controller automatically. It will use a beans scope. You can list more than one. (Love this.)

Caching Updates

Gesture won't have an object cache - thats for your service layer. But a very simple content cache will be added.

<event-handler name="page.home" cache="true" />

This will cache the HTML result into RAM. You can tweak timeout. You can also cache into different scopes, and supply specific keynames for the cache. Keyname="X" means, the name of the cache is based on the Event value for X. So one event can have N different caches. So a product detail page would use the productID for the cache key. You can also invalidate a cache.

MG's cache is intentionally simple caching system since most folks have very personal/specific ways of needing to cache. MG makes it easy to swap out it's system and use your own. (Like JDBM or memcached.)


Joe is on the fence on this one. Apps have to work with multiple formats - HTML, XML, JSON, Partial pages. It's providing the same data in N formats. Which stinks. In gesture, you can tell an event to run based on a format. Like requestFormat=JSON. So you can tell broadcast tags, views tags, and results tags to run on format=X.

<event-handler name="x"> <broadcasts>....</broadcasts> <views format="json"> .. </views> <views format="xml"> ... </views> <views format="custom"> ... </views> <results format="html"> ... </results> </event>

Model-Glue Remoting

A typical CF app will contain HTML, Flex, Flash, etc. Your app can have both an index.cfm file at root plus a ModelGlueGateway CFC as an entry point for Flex/Flash thingies. You can call events from Flex/Flash:

<mx:RemoteObject id="modelGlueGateway" desitnation="ColdFusion" source="ModelGlueGatway">

I can't type this fast, but he basically uses the gateway to run a MG event (all via ActionScript).

Edited a few minutes later...

You can now support unknown events. Ie, if event X is requested and not supported, you can tell MG to run event Y to handle it instead of just having an error thrown.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Raul Riera posted on 5/3/2008 at 8:37 AM

it would be nice to have a REALLY good video tutorial about ANY framework... I have been watching Ruby on Rails tutorials on and they ROCK, I wish there was something like that on ColdFusion so I could really see which framework to choose from (if any)

Comment 2 by Jeremy Prevost posted on 5/3/2008 at 9:17 AM

Joe's presentation slides are included with the alpha download of MG3 in the documentation folder.

Comment 3 by Bruce Embry posted on 5/4/2008 at 7:45 AM

Will you be posting the slides from your presentations?

Comment 4 by Raymond Camden posted on 5/4/2008 at 5:43 PM

Yes, late tonight most likely.

Comment 5 by Shimju David posted on 5/5/2008 at 12:41 PM

Event generation feature is pretty sleek and really a time saver.. Helpers are really a HELP. Bean Injection is simply WOW!!

The new "Formats" feature needed more explanation.. It will be really great if you or Joe can write an article focusing this special feature with a small AJAX integration example if possible.

I know it is in Alpha and just want to notice few issues which I faced when I played with it:

1) Built-in SES URL feature not working for me.
2) event.forward() not seems working
3) When we add a new coldfusion UDF file inside '/helpers' folder App needed an init=true to access the new udf functions in 'helper scope' even though reload mode is turned on.

Comment 6 by Steve Bryant posted on 5/6/2008 at 2:52 AM

I had read this blog entry before attending Joe's CF.Objective presentation on Model Glue 3 and I was still surprised by the coolness of the features when he talked about them in the presentation.

Very impressive stuff!

Comment 7 by Yaron Kohn posted on 5/6/2008 at 6:32 PM

Any coolness regarding MG3 & CF8 Ajax intergration?

Comment 8 by Raymond Camden posted on 5/6/2008 at 7:07 PM

Not really - that would add things to MG that would require CF8, which I don't think Joe wants to do. Obviously you can use CF8 Ajax stuff w/ MG - right now - and it just gets even nicer in MG3.

Comment 9 by Steve Bryant posted on 5/6/2008 at 7:31 PM

Personally, I thought the "Formats" feature is pretty cool for AJAX stuff.

It allows you to define different views for different formats for any event.

So, you could have one event with both an HTML format and a JSON (or WDDX) format so that the event could be requested from an AJAX control.

Pretty nice stuff for code reuse across multiple formats (including AJAX).

Comment 10 by Shimju David posted on 5/6/2008 at 7:36 PM

Steve, can you show an example for format stuff. an example contact manager app is enouugh?
I didnt really understand this feature in the new MG3 feature list.

Comment 11 by Raymond Camden posted on 5/6/2008 at 7:38 PM

I'm planning some blog posts this week specifically on new MG stuff, with examples. (Not to stop Steve of course. ;)

Comment 12 by Shimju David posted on 5/7/2008 at 10:38 AM

Thanks Ray, Kindly start with "Formats" feature :)

Comment 13 by Shimju David posted on 5/13/2008 at 11:46 PM

Thanks Doug for sharing this
Couple of days before I pointed that SES URL feature didn't worked for me by default while I tested MG 3.0. I thought It was a bug as MG3 is in ALpha. As per Doug suggested I used the second way by defining the URL manager bean in my CS.XML file as
<bean id="modelglue.UrlManager" class="ModelGlue.gesture.eventrequest.url.SesUrlManager">
<property name="modelGlue">
<ref bean="modelglue.ModelGlue" />
and it is Working.

Comment 14 by Shimju David posted on 5/13/2008 at 11:53 PM

Finally, the best features so far I liked in MG3.0 (which worked for me) listed in the ascending order are:

1)Event generation
2)Bean Injection
4)Built-in SES URL

Iam now looking for "Formats" feature which not tested yet as It is not clear now and needed clarification. Ray can you please blog abt it in detail.

Comment 15 by Raymond Camden posted on 5/13/2008 at 11:57 PM

My next post is on app.cfc integration. I will do formats either later this week or late next week (I'm in DC for WebManiacs early next week.)

Comment 16 by Shimju David posted on 5/14/2008 at 8:45 AM

MG3: Application.cfc integration already blogged by Joe.

Comment 17 by Raymond Camden posted on 5/14/2008 at 3:14 PM

Curses. Oh well, I'll look into a formats demo next then.

Comment 18 by Darren posted on 5/16/2008 at 2:23 AM

I'm just starting to mess around with MG3. Love the new features. I was wondering about the action packs (usermanagment specifically) that come with the Alpha. Does anyone know of any resources that discuss how to plop this action pack into an application. I can't see to find any discussion about how to use it.

I'm sure it's very simple but I don't have a starting point. :-(

Comment 19 by Dominic Watson posted on 5/17/2008 at 4:29 PM

Woe is me; the MG site is down; oh well, I'm sure it will reappear... can't wait

Comment 20 by Darren posted on 6/19/2008 at 2:52 AM

Just for clarification, is the Model-Glue Remoting functionality you mentioned (ModelGlueGateway) currently included in the Alpha download of Model Glue?

I was trying to use it via the cfajaxproxy but not having much luck.

Best Regards,


Comment 21 by Raymond Camden posted on 6/19/2008 at 4:36 PM

I don't believe that is public yet. When I see Joe I'll ask him.