Using remote functions with JQuery but you want to use XML pass the query paramters?

ColdBox, ColdFusion

Are you using remote functions with JQuery but you want to use XML pass the query parameters? If you aren't you should be.

Well, why in the heck would I suggest such a thing? It's because Steve had the brilliant idea to reduce execution plans on the database using this nifty trick. So if we combine frequently used GET type queries (AKA get stuff from tablename where blah) into a single query and use a parameter to tell the stored procedure what to return we can reduce plans and improve server performance. So wow cool idea, but umm I'm calling the model directly dude. Steve being a DBA says, "why can you just generate XML like you always do?". Well as most Coldboxers should know, "When you call a CFC from the URL like that, it isn't autowired.  This is because the CF engine just creates a CFC instance directly and WireBox doesn't have a way to intercept that."  (Thank you Brad)

What does this mean? My handy dandy tools like my XMLConverter and populateModel tools aren't available. Loving my framework the way I do... I think, oh hell, I'm not going to manually write my own special XML tool. I'm way too smart, well lazy, for that.

So Brad tell me ....

"ColdBox 4 does have a new feature though, where CFCs that extend the base proxy class will get autowired in the pseudo-constructor.  Otherwise, you'd have to do something like application.wirebox.autowire( this ) in the CFC.  Or, for that matter, application.wirebox.getInstance( 'foo' )."

Well I'm not at CB4 yet. So I guess I'll call the autowire my darn self.

 Here is an example. 

component extends="baseService"


application.wirebox.autowire( this );

remote query function test(numeric param1=0,numeric param2=0)


            LOCAL.xml = XMLConverter.structToXML(Arguments);





Now being a lazy programmer, my hand dandy XMLConverter that can take a struct and make it XML autoMagically is injected in my base model (typing is hard work ya'll). Since this this model initializes wirebox and extends the base model I can use it. Yee Haw. Normally, I use populateModel to grab the form data and convert it a model that is a struct and then convert that to XML. But in this case as I pass stuff into the model it becomes part of the arguments struct so it already created my struct for me. Sweet! Just replace my dump with the usual stored procedure call and the DBA is happily processing XML.

Warning: Please don't be a dumb dumb and use this method for sensitive data. Use a handler so you can do things like an interceptor or a prehandler to check that the person asking for data is supposed to be getting the data. We only use this for frequent reference table type information. We NEVER use this to save data. 

Here's to being smart, um lazy. 




ColdBox, ColdFusion

I started getting this issue when using CFDOCUMENT one day. 

cfdocument Parsing problem occurred during the rendering process of this document.

I typically use Coldbox as a framework so in this case I had a layout where I was CFDOCUMENT to do all my PDF "rendering". So the customer reported to me that the server has an issue creating PDFs. I tried everything only to learn the basically CFDOCUMENT if very picky when it comes to W3C validation. In my CFDOCUMENT, I had done a CFINCLUDE on my CSS. That CSS was the cause of my IOException problem.

<style type="text/css" rel="stylesheet">

        <cfinclude template="/includes/css/style.css"  >


I modified my CSS and the problem went away. So hopefully this saves you some time.

Validate your HTML:
Validate your CSS:

CFHTTP using script

So I thought since CF11 allows the use of script tags that maybe I had a work around for the Update 3 bug. I rewrote my code as shown below but I still get the issue with the file being empty.


function elasticEmail2(event,rc)



cfhttp(result = "LOCAL.result",method = "put",

        url = "",

        getAsBinary = "yes")


        cfhttpParam(type = "file",name="EGTest",file="c:\somefolder\test.csv",mimetype="Content-type: text/csv");






  cfhttp(result = "LOCAL.result2",method = "post",

        url = "")












Bug filed here:



Coldfusion 11 Update 3 has an issue with using HTTP to put files


So I've blogged about all this Elastic Email stuff. One of things that I do is create csv files that are then posted via API using http to Elastic Email using the mail merge API.  I recently migrated servers and suddenly had a issue. I was previously using CF9 and everything was good. Well I jumped all the way to CF11. I had tested my code in Dev which was CF11 so I thought I was good to go. Well I didn't check but my dev server was running 11,0,0,289974 and prod was running update 3. I downgraded and I was back in business.

As the updater says....

"ColdFusion 11 Update 3 includes support for JDK 8, Tomcat 7.0.54 and other platforms/servers/databases besides ~195 bug fixes (internal and external) in AJAX, Charting, Caching, Database, Language, Mobile Support, Net Protocols, Security and other areas."

....but it also introduces a cfscript http put bug.


Elastic Email File Upload for attachments and mail merges


Here is a simple function for use with Elastic Email for uploading files. The file can then be used for mail merges or sent as an attachment. If you look at my previous post you will see:


This is the name of the file that is uploaded by the upload function. So with this you send an email using a template which the variables are populated dynamically from a bean to csv file full of recipients.


    public string function elasticEmailUpload(upLoadName,fileName)
            LOCAL.httpService = new http();
            LOCAL.uploadURL=THIS.UPLOADURL & ARGUMENTS.upLoadName;
            LOCAL.httpService.addParam(type="file",name="#ARGUMENTS.upLoadName#",file="#ARGUMENTS.fileName#",mimetype="Content-type: text/csv");
            LOCAL.result = LOCAL.httpService.send().getPrefix();
            return LOCAL.result.Statuscode;