Most commercial systems I've worked with implement this in a much simpler manner: by simply adding a datestamp to the row in question.
When you render the edit form, include the datestamp as a hidden field.
When the user submits the update, compare the datestamp with the one in the row. If the row contains a newer one, there's a overwrite issue. Ask user to confirm they want to overwrite, maybe give them some idea what's changed.
Bonus points for using ajax to notify open clients of the row change while they're editing the records.
I think this is orders of magnitude simpler than your attempt to reinvent client/server locking behavior in the browser (which might just be a first - which should scare you), and it's backed up by lots of prior art, so you know it will work.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|