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

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -