Friday, September 7, 2012

getApplicationSettings() Part 2

In the last post I talked about the getApplicationSettings() method, and how we previously used it to look inside the application scopes of other applications in Coldfusion 8.  Well one of the first things I noticed when working with our application administration tool in CF10 is that this function changed in version 10, which was leading to errors.

That's the danger of relying too much on undocumented features!

Most specifically, in CF8 the getApplicationSettings returned us a struct, now it returns a class of  type coldfusion.runtime.ApplicationSettings.

This was rather bad for me, because in the old CF8 version the struct contained, among other things, a further struct with all the custom mappings for the application. A quick glance at the new object showed  that my mappings were nowhere to be found.

So now what? I created an object of type applicationScope and sniffed around.

 <cfset app = createObject("java","coldfusion.runtime.ApplicationScope") /> 
 <cfdump var="#app#">

The answer was pretty easy to find. The new getApplicationSettingsMap() function returns the struct that I used to use in CF8. One quick fix and my tool was back up and running.

Of course it is worth pointing out that this whole change probably happened because of the new getApplicationMetaData function, which gives me a "documented" way to get at some of the things I could only see through sneaky means in the past.

If you just need to see the meta data of the application of the calling template, use that instead.

No comments:

Post a Comment