« The right tool in the wrong hands | Main| Nifty... modules? »

Create, edit and delete without agents

Category Show-n-Tell Thursday
I'm really becoming a broken record, eh? Or, for you kids in the audience, a degraded MP3 file. By request, I put together a full demonstration of how documents can be created, edited, and deleted using AJAX, all without the use of any agents. You can try it out here. And you can download the demo database here.

Previously, I described how documents can be created and edited in a Domino database without calling agents. This demo combines the two - as well as deletion of documents - using a simple contact manager as an example. The UI is very primitive, but hopefully it illustrates the premise.

In this example, contact information can be entered and then posted to the server without a page refresh. The function that posts the document (thereby creating a new record in the database) in turn calls the function that loads the view data (thereby displaying the newly created record). The new data could of course be inserted into the table immediately instead of reloading the view, but this approach was intended to illustrate how much faster document creation is when agents aren't involved. Reloading the view also ensures that the new record will already be sorted correctly when it's added to the table. In addition to document creation, each view row includes a link to allow editing and deletion of existing documents.

Please feel free to post any questions or suggestions you may have about this... I was planning to write up a far more detailed explanation of how all of this is tied together, but I'm suddenly very sleepy.

Oh, one thing I should mention: the reference to Event.onDOMReady at the end of ajaxeditor.js isn't part of the core prototype.js. It's an extension I found on Vivabit. This allows functions to be defined in external js files that would otherwise need to be called inline or via window.onload... for example, functions that you want to run immediately, but not until some DOM element that the function is going to muck with is actually ready to receive said mucking. The primary advantage of this extension is that it triggers the functions as soon as it is safe to do so, instead of waiting for the entire page to load (images, for example).

Comments

Gravatar Image1 - Lamon, I'm not sure why the online demo would support Chinese while the downloadable demo did not, because the code is identical, but I admit that I did not specifically attempt to support foreign languages when I wrote this demo.

Gravatar Image2 - hello Tim!
I come from china,and I download the demo and setup in my domino server,it not support chinese language,but I test in your online demo:[url]http://www.timtripcony.com/test/ajaxeditor.nsf[/url],it support chinese language.
I don't know what happen.

Hire Me

Elsewhere

What the Quote?

"We could do a lot to reduce the rate of construction accidents if we could just get those 5 year-olds with head-colds off those bulldozers."

Chad Schelfhout

"We thought we'd be brilliant and just copy your code, and your code said, 'Yeah, you're funny'."

Monica Ferrante

"Their server's been down five thousand minutes? Ya can't even find cell phone plans that high."

Steven Rodgers

"Put that on your Quote Board and smoke it."

Laura Tripcony

"I'm not going to forget that for the same reason scars don't heal."

Tim Tripcony

Apparel

Lotus Rocks

I write the code that makes the young girls cry