Rob Gonda's Blog

ajaxCFC update for DRWUtil.AddRows

A recent message in the ajaxCFC group asked about the DRWUtil.addRows() function; the truth is that I had never used it. I include the utils library because there are other elements that I find useful, but I had never given the addRows a try.

Enough said, since I include the file, I guess I need to support the built-in functionality, but the addRows out-of-the-box was accepting arrays and objects. I serialize the ColdFusion queries into a more complex object which was not recognized by the addRows function, so I modified it to add wddx support. When you pass a wddx object to addRows it will now automatically populate your table, even without the need to cell functions (like the array or object methods).

You can find an example here, and download the latest release (0.63) with the code changes, example, and updated documentation from the projects page.

I'd like to thank again Joe Walker for his great effort in putting DRW together, and I will email him the changes to add wddx support for his next release.

ajaxCFC port for the Model-Glue Framework

The latest fad in the Model-Glue list has been AJAX. How to incorporate Ajax requests to the Model-Glue framework. Is it pointing directly to the model? To the controller? or going thru the full cycle by pointing to index, then controller, model, back to the controller, and passing arguments back to the view?

I ported ajaxCFC to work with Model-Glue and it came out great. It works just like any other MG event, where you have to define it in the config.xml, create a listener, use the controller, models, and views... it's beautiful. All ajaxCFC's add-ons like security and debugging work file. Request batch, complex objects, verbs, and sync requests possibilities still apply.

You can see it in action here. To make this example work you need to download the head revision from the Model-Glue framework. The only reason why the stable release would not work is that you cannot suppress debugging in a template-per-template basis.

I added the MG-echo example in the main ajaxCFC download, which also includes a modified version of ajax.cfc and engine.js. I will try to combine the stand-alone version with the MG one in the future, but for now, I will support both of them separately.

Enjoy.

ajaxCFC: addressing html code in application.cfc

I just got hit with an email informing me that ajaxCFC will break when application.cfc adds code onRequest(start|end). I modified the framework to reset the content before the JavaScript response, and abort it at the end of the asynchronous call. I am not quite happy with the abort though, so if someone has a better solution to eliminate all code generated by onRequestEnd please comment it here. I tried to open a JS comment segment, but then it results on unfinished comment; setting enable cfoutput only will only work if the code in application doesn't use cfoutput; cfsilent needs an ending tag.

The abort works for most of the cases; the AJAX request will always work, but if you had some custom code in your onRequestEnd, such as logging, it will not be executed.

Note on application.cfc: as a general rule, try to avoid using application.cfm/cfc for html rendering. It is advisable to separate your logic from the presentation layer. Application.cfc, just like any other component, is encapsulated and parameterized, and should not display html. If you successfully separate your logic from your views, you will be able to use the same architecture for presentation layers such as html, ajax, flash, flex, laslo, or mobile devices.

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.

ajaxCFC: updated documentation

I just updated the ajaxCFC project download file to include the dynamic JavaScript example and updated documentation. I added explanation to handle different return types from CF; this was meant especially to handle Queries, for which I received several requests.

ajaxCFC: server side JavaScript and dynamic content

To illustrate the idea of my previous post, I just added an example that stores the JavaScript in the server side and leaves only core connectivity and UI functionality in the client side.

It uses a simple DHTML popup windows library and sends the instruction along with the content back to the callback function, which simply executes the server’s request.

This example is not a full application and is far from perfect. It has no validations, no even listeners, or any advanced functionality. It is only meant to show how to control your JavaScript code in the server instead of the client.

ajaxCFC official yahoo group

Following the suggestion of some of my readers, I just created a Yahoo Group / Mailing List for ajaxCFC. This group may facilitate the communication among ajaxCFC users, sharing, discussing, requesting help, or _showing off_.
 
http://groups.yahoo.com/group/ajaxcfc/

On a different note, I updated the L&F of the examples and added a couple more. I am also working on blowfish encryption to allow for secure data exchange. If any of you are cryptography experts, I could definitely use your help :)

ajaxCFC with security and debugging released

I just uploaded a new release of ajaxCFC with some really nice additions.

ajaxCFC now supports built-in improve security, enforcing get or posts verbs, and also optionally checks for the http-referer to match your site. These two checks will prevent a third party to monitor http packets and try to call them manually by pasting the full ajax request to a browser.

I personally always Firefox and Live HTTP headers debug my ajax applications and I recommend using get methods and allow blank referers for development environments; but you need to be able to lock it down for production.

And talking about development, don't you hate when you think you're doing everything right, but there is no way to see what the server is getting out of your ajax request? I added some debugging abilities too that write into a debug file.

More details on the implementation of these updates are available in the documentation inside the download.

week full of releases

There two main JavaScript frameworks used for Web 2.0 and Ajax are Prototype and DRW.

This was a week full of releases; Prototype 1.4 final was released today (although they haven’t updated their site yet) and it’s required to script.aculo.us 1.5, which was also released today. Script.aculo.us is used to Ruby on Rails, which was released this week.

A new version of ajaxCFC with increased built in security will be released next week.

ajaxCFC small fixes

I just updated the project files to include the following fixes:
 

  • replaced the /exec/method after the CFC call with get or post vars because it was being misinterpreted by some web servers
  • Forced ColdFusion debugging to stay off for ajax calls because they were breaking the JavaScript response.
Thank you Steve and Tony for your help.

More Entries

This blog is running version 5.9.003. Contact Blog Owner