This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 18, 2011, 12:23 PM
7 Posts

Best Practices for Document Locking in XPages??

  • Category: Forum design
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: XPages,Document Locking
  • Replies: 3
Hi,
 
I'm trying to implement Document Locking in XPages, basically I want to avoid replication conflicts when multiple users edit the same document at the same time.

If a document is being edited by userA; I'd like to display a DialogBox or Alert to userB (saying that doc is being edited by userA) when he tries to edit the same document.
 
I already checked concurrencyMode property and it's not what I need.
 
I have this link too http://www.empachal.com/pf_cable/blog.nsf/d6plinks/PCAE-862MU3
 
Any help will be appreciated.
Apr 25, 2011, 8:14 PM
64 Posts
Re: Best Practices for Document Locking in XPages??
- I did this a while back and it's not pretty, but I also did it under 8.5.1, and haven't had the opportunity to code in a new version, so if things have improved I'm not a good resource.  I can't produce code for you, but the gist is this:
 
1. Lock the document use SSJS in beforePageLoad on the server.  If it's locked already don't load the page, fall back and tell them it's busy.
2. Unlock the document using an AJAX call in onunload in CSJS on the client.
 
- Locking it on the server ensures that you can absolutely prevent the page from loading if it's already locked.
- Unlocking it on the client ensures you can reasonably unlock when you're done.  Unlike beforePageLoad, there is no server-side event you be sure will always run when the user is done ... if they hit the back button for instance, the lock is left behind.  "That can't be good." - Porko Rosso
- Fly in the ointment is onunload runs at odd times, so you run the risk of unlocking something you didn't want to unlock.  Since browsers run onunload they way they do for security reasons, ostensibly, this is how it is.  A complex set of CSJS tracking data can minimize but not completely eliminate this effect.
- The hack is scheduled Agent that cleans up the stale locks.
 
Hope this helps...
Apr 10, 2014, 9:40 PM
2 Posts
Any new information on this?

I have multiple users updating the same documents and lots of replication conflicts - does anyone have any more recent information on document locking for xPages?  Thx.

Apr 11, 2014, 11:29 AM
298 Posts
Kind of the same as in traditional Domino web
First of all, you should be using authors fields to limit who can change a document if possible.

Then, if you neeed true locking you can write code to lock the doc when  opened and unlock it when saved/closed. Typically developers setup a lock database that writes a record out to it with the doc unid of the document to lock/unlock.

Howard

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal