Over the weekend there was a chain of messages on the Model-Glue list about how to get SES Urls working in Model-Glue 3. This is actually quite simple, but the best technique is not immediately apparent. Respondents on the mailing list had it pretty much right but missed an important capability of Model-Glue, which is enabled by the use of ColdSpring.
First off, Model-Glue 3 introduces the concept of a UrlManager. Most people will probably never have to deal with this component, but, behind the scenes this is what essentially populates the event with values from the URL and form scopes.
If you were to dig into the Model-Glue 3 core ColdSpring configuration file you would find a bean with an id of “modelglue.UrlManager” which is of type “ModelGlue.gesture.eventrequest.url.UrlManager.” If you were to look under the /ModelGlue/gesture/eventrequest/url directory you would find two files, UrlManager.cfc, which is the default URL Manager and SesUrlManager.cfc, which we are not configured to use.
The SesUrlManager.cfc is the URL manager you can use with SES Urls. This component knows how to parse urls with this format:
So, the question then becomes, how do I use the SesUrlManager instead of the standard UrlManager? Easy, just update Model-Glue’s configuration. There are two ways to do this.
The first and most obvious way is to edit Model-Glue’s core configuration file and change the “modelglue.UrlManager” bean to “ModelGlue.gesture.eventrequest.url.SesUrlManager.” However, this introduces a problem. Namely, every application which uses the instance of Model-Glue you edited will now be using the SesUrlManager, which you may not want.
The second and not-so-obvious way to do this is to simply define the “modelglue.UrlManager” bean into your application’s ColdSpring.xml file. Behind the scenes, when Model-Glue is loaded, in the /modelglue/modelglue.cfm file included by your index.cfm, the framework creates a ColdSpring bean factory and loads beans from the core Model-Glue configuration file. Then, it loads all the beans from your ColdSpring configuration file. Any beans in your ColdSpring configuration that already exist in ColdSpring are overwritten by your configuration.
So, by placing the “modelglue.UrlManager” into your configuration file you’re non-destructively overriding how the Model-Glue framework works. This is, quite frankly, my favorite feature of the framework. You can apply this same technique to any ColdSpring-configured Model-Glue object. I actually wrote a blog entry on this a while back: “Extending Model-Glue via ColdSpring.” I’ll be talking on this and other Advanced Model-Glue topics at both WebManiacs and CFUnited!