Mach-ii 1.8 Upgrade Error

Upgrading Mach-ii to release 1.8 from 1.5 produced an exception error in our application on some saves.

Message
Event-handler for event 'index.cfm' in module '' is not defined.
Detail
Check that the event-handler exists and for misspellings in your links or XML configuration file.

The URL looks like this:
https://www.mysite.com/index.cfm/event/index.cfm?event=MyNextEvent&message=Your%20changes%20have%20been%20saved§ion=options

Notice the "index.cfm" appears twice in the URL. It seems that the URL is no longer being built correctly. We don't really have any SES URLs, so what needs to be adjusted for Mach-ii 1.8?

In mach-ii.xml there is a applicationRoot property which is set to "/".

view plain print about
1<!-- PROPERTIES -->
2<properties>
3        <property name="applicationRoot" value="/" />
4        <property name="defaultEvent" value="showHome" />
5        <property name="eventParameter" value="event" />
6        <property name="parameterPrecedence" value="form" />
7        <property name="maxEvents" value="200" />
8        <property name="exceptionEvent" value="exceptionEvent" />
9        <property name="exceptionMode"
10</properties>

I did a command search for "applicationRoot" to see how it impacts URLs. It shows up in the "Mach-ii/framework/viewLoaders" directory. My exception is being thrown on an event and not a view, so "applicationRoot" is not the key to this solution.

So looking through the Mach-ii directory, we see templates like UrlRoute.cfc. What does that do? Well it looks like it deals more with SES or SEO Urls, nothing as basic as what we are trying to accomplish.

http://trac.mach-ii.com/machii/wiki/MachII1.8SESImprovements has a buildRouteUrl() function with example syntax:

view plain print about
1buildRouteUrl("routeName", "urlParameters", "queryStringParameters", "urlBase")

So what's this "urlBase"? http://trac.mach-ii.com/machii/ticket/641 has a lengthy discussion and explains the difference between "applicationRoot" and "urlBase". The applicationRoot property has to do with your CFML engine finding files on disk (such as views) and not how URLs are built. URLs are driven off of urlBase which could have a full host in their as well.

So the bottom line here is to add the urlBase property to mach-ii.xml:

view plain print about
1<!-- PROPERTIES -->
2<properties>
3        <property name="urlBase" value="/" />
4        <property name="applicationRoot" value="/" />
5        <property name="defaultEvent" value="showHome" />
6        <property name="eventParameter" value="event" />
7        <property name="parameterPrecedence" value="form" />
8        <property name="maxEvents" value="200" />
9        <property name="exceptionEvent" value="exceptionEvent" />
10        <property name="exceptionMode"
11</properties>

Reinit the application and it works like a charm! No more URL goof ups.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner