ajaxCFC query retrieval example
Due to popular demand, I added an example that populates fields with information retrieved from a query. It actually has two versions of the code: one using client side JS and one using server side JS.
I created a query in ColdFusion so you do not depend on an external database to run this example. You should be able to easily replace the one I created with a real database.
As usual, I also added it to the download.
http://www.robgonda.com/blog/trackback.cfm?932A831B-3048-7431-E4CD8FC82CFDB13F




Thanks for this awesome example and clear explanation. I especially like the server side javascript/ AJAX.
Here are a couple links that your readers might be interested in to complement your posting:
http://jr-holmes.coldfusionjournal.com/calling_cf_...
http://www.indiankey.com/cfajax/examples.asp
Mark Holton
Coldfusion Developer
holtonma@gmail.com
http://holtsblog.blogspot.com/
Please note also that I am not using cfajax; as the matter of fact the main reason I built ajaxCFC is because of some lack of functionality of cfajax. Initially I contacted Arjun offering a bunch of upgrades I performed to his framework, and after no response for a few weeks, I decided to develop something better.
Anyways, those examples will not work with ajaxCFC. They are adaptable, but it is not the same methodology.
Please do not hesitate to critique my work, since that is the sole energy to build new and improved features.
And the first example just sends data?
Thanks.
Btw, how does dwr play with prototype and scriptaculous, and what advantages did you see with dwr over prototype?
In the first example returned the dataset and the call handler parsed the data and assigned to the fields. In the second example, the server already writes the JavaScript and sends back the full command, which the handler function blindly executes. With this approach, 1) There's only need for one callback handler function, 2) You can secure more your JS, 3) Only load it when needed.
I am working on an example where you dynamically load functions into a namespace, allowing you to, for example, load the prototype, scriptaculos, or any other JS on-demand, and leave it in a local namespace after loading for future requests.
Now, scriptaculos does not work with DWR, as you probably know, it needs prototype; or maybe prototype-lite, not sure if it will work. You would have to load all of them, just like you would to use Rico, or load Dojo if you wanted to use that. This would be a good example where you could load them on-demand, and use a nice AJAX preloader after the core framework had been loaded.
Comparing prototype with DWR is more complicated; just like comparing them to Atlas… There're both have advantages and disadvantages, and honestly, I have not benchmarked them. If I have the time I could make an ajaxCFC version for prototype, but I don't see that coming anytime soon.
I was more so wondering about your general impression of prototype vs. dwr for ajax, i.e., what's missing in each, easy in each, and such. I do realize prototype has more general hooks in it for development such as event handlers and such. Thing is I use a highly optimized library now for that, so was leaning more towards prototype as a replacement with it's ajax/json on top. Then again, I use cf, so...
Thanks,
-Rob
thanks,
thanks,
function query_response(r){
var getLabel = function(result) { return result.processLabel };
var getLevel = function(result) { return result.processLevel };
DWRUtil.removeAllRows("tableBody");
DWRUtil.addRows("tableBody", r, [ getLabel , getLevel ]);
}
http://www.robgonda.com/blog/index.cfm/2006/1/18/a...