Friday, November 21, 2008

Avoid save-conflicts in web applications

I had a problem with save-conflicts today.

In an app I work with, the users can modify the category a document belongs to from the document-editing interface. When the category is saved, all documents that belong to the category are updated with new paths.

Sometimes, when a user saved the document after modifying the category, a save-conflict would occur (I couldn't recreate the save conflict in Firefox for some reason, only IE).

I searched the forums for help, and found it (thanks, Erik C. Brooks). If you remove the %%ModDate front-end with Javascript, you avoid save-conflicts. I tested it, and it seems to work. To be somewhat on the safe side, I only remove the field when a category is being modified from the document-editing interface.

Simple code to remove the field:
var f = document.forms[0];
f.removeChild( f['%%ModDate'] );

0 comments: