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.
Well I'm not at CB4 yet. So I guess I'll call the autowire my darn self.
Here is an example.
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.