Blog Projects
Escape Keys
A ColdFusion and Web Development Blog by Tom de Manincor
 

A few updates were made in the 0.4 release available at:

salesForceCFC @ riaForge

A major and a minor fix have been implemented. The major being the lack of xmlFormat() in earlier releases. This would prevent characters like '<' to be passed as part of a queryString when using the queryObject() method.

There is now methods to manipulate the timeout value for SOAP requests and a getMemento() method that will return all values stored with the instance.

0.4 -CHANGE LOG- 4/5/2008
- enhancement - added timeout handling for cfhttp
- enhancement - added getMemento()
- fix - added xmlFormat() to query and save methods
- fix - disabled throwonerror for cfhttp to return accurate success

I am on the fence over the throwonerror setting, and looking for some feedback.

I whipped this up to contribute to Rolando's environmentConfig project.

ColdSpring doesn't like being passed complex values, and it's not that big of a deal unless you are parsing settings from a 3rd party XML, that builds them into a nested struct.

So we came up with this to build all the nested structs into a single struct. By default it adds the parent struct's key as a prefix. This is to assure no values are overwritten.

I didn't see a UDF on CFLib for it, so I figured I'd submit and post here in case it can help anyone else out.

<cffunction name="flattenStruct" access="public" output="false" returntype="struct">
   <cfargument name="stObject" required="true" type="struct" />
   <cfargument name="delimiter" required="false" type="string" default="." />
   <cfargument name="prefix"     required="false" type="string" default="" />
   <cfargument name="stResult" required="false" type="struct" default="#structNew()#" />
   <cfargument name="addPrefix" required="false" type="boolean" default="true" />
   
   <cfset var sKey = '' />
   
   <cfloop collection="#arguments.stObject#" item="sKey">      
      <cfif isSimpleValue(arguments.stObject[sKey])>
         <cfif arguments.addPrefix and len(arguments.prefix)>
            <cfset arguments.stResult[arguments.prefix & arguments.delimiter & sKey] = arguments.stObject[sKey] />
         <cfelse>
            <cfset arguments.stResult[sKey] = arguments.stObject[sKey] />
         </cfif>
      <cfelseif isStruct(arguments.stObject[sKey])>
         <cfset flattenStruct(arguments.stObject[sKey],arguments.delimiter,sKey,arguments.stResult) />   
      </cfif>
   </cfloop>
   <cfreturn arguments />
</cffunction>