xpages - Managing custom document locking to prevent conflict document -


i have custom document process built ssjs object. when click on edit button in document in read mode, call method sets lock date/time , lock owner in backend document , returns true. changedocumentmode simple action can used change document edit mode. however, first time save document (such simple action), creates conflict document. frontend document not aware of backend document modification , save did before going edit mode.

if change process let document locking code set 2 backend doc fields , use context.redirecttopage, document opens edit mode , saving ui not create conflict documents. however, if after using code unlock document use open page simple action go "previous page" exit document, goes read mode instead of closing document. sure initial redirecttopage disrupted history , causes problem.

the question: have suggestion on how can lock document before going edit mode, go edit mode, save without causing conflict documents, , still able exit using open page simple action (after unlocking document)?

here sample of relevant code locking, including code go edit mode:

thisdoc.replaceitemvalue("lockowner",context.getuser().getcommonname()); thisdoc.replaceitemvalue("lockdate",session.createdatetime(@now())); thisdoc.save(); var url = view.getpagename()+"?action=editdocument&documentid="+thisdoc.getnoteid(); context.redirecttopage(url); 

it depends on use case. if application way users access documents, recommend not write documents locking - end need unlock admin function users disconnected (network, close browser, crash) before unlocking. way locking done e.g in webdav in-server-memory time lock call renews every 30 seconds. use classic ajax call that.

the openntf webdav domino project has server side of such locking mechanism, might want copy there.

in case must write document: change sequence , update document in queryopen event in readmode - covers cases user had bookmarked edit url too.

let know how goes!


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -