This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am writing an app for multiple users and I need to lock/unlock records while users are updating information. My problem is with unlocking because a user can just close the browser and forget to unlock the record. I tried using the unload event as shown below but it doesn't work.
The alert box will display but then nothing happens and it never goes back to the servlet. Any help would be greatly appreciated. Thanks, Ezra
This is the most commonly asked question in this entire forum. Do a search and you'll find it answered many times. The answer is you can't. There's no way to communiate to the server when they close the browser. The closest you can come is to use the HttpSessionBindingListener interface so that when the user's session times out it closes your files, or unlocks your records, or whatever. By the way, I would consider any implementation that locks records between HTTP calls to be HIGHLY suspect. You really shouldn't do that! Try using optimistic concurrency (timestamps) instead of pessimistic concurrency. Your life will be much easier in the long run. Kyle