Checks the existence of a [page lock].  A [page lock] is created when an user starts editing a page.  You can use this tag to warn the user, prevent the page from being modified (by removing the editor text area, for example), etc.

----

!Usage

<wiki:~CheckLock mode="locked|unlocked|owned" id="<variable>">
;:''content''
</wiki:~CheckLock>

!Parameters

;__mode__: If set to "locked", will include the content if the page has been locked.  If set to "owned", will include only if the page is locked by the current user.  Value "unlocked" includes if the page is not locked.
;__id__: The JSP variable named in this parameter will be set to an instance of ~PageLock class.

!Example
{{{
      <wiki:CheckLock mode="locked" id="lock">
         <P CLASS="locknote">User '<%=lock.getLocker()%>' has started to edit this page, but has not yet
         saved.  I won't stop you from editing this page anyway, BUT be aware that
         the other person might be quite annoyed.  It would be courteous to wait for his lock
         to expire or until he stops editing the page.  The lock expires in
         <%=lock.getTimeLeft()%> minutes.
         </P>
      </wiki:CheckLock>
}}}

!The ~PageLock class

The ~PageLock class has the following methods you can use:

;__public WikiPage getPage()__: Returns the current page.

;__public java.lang.String getLocker()__: Returns the user name as a string.

;__public java.util.Date getAcquisitionTime()__: Returns the timestamp when this lock was acquired (i.e. the user started to edit the page.

;__public java.util.Date getExpiryTime()__: Returns the timestamp when this lock expires (if the user has not saved or clicked "cancel")

;__public long getTimeLeft()__: A convinience method, which returns the remaining time to expiry in minutes.


----

[CategoryOfficialDocumentation]


----

Which JSP(s) would need this tag added to be able to lock the text editor from any editing? Also, could this tag be added on the Logout.jsp to release any locks which the user had?

--AnonymousCoward, 12-Aug-2008

Wrap the EditorTag (in EditContent.jsp in 2.6) inside a CheckLogTag with mode="unlocked".


----

I attempted using the CheckLock tag as you mentioned, with the mode set to "unlocked," and found that the editor would not show up at all. It seems like when you click to Edit a page, the page will lock first and then the CheckLock tag will see that the page is locked and the editor will not show, thus making the editor impossible to see. I tried using the "owned" attribute and that worked better. But, I fell into another problem, though, as I locked a page, logged out, logged back in, and attempted to edit the same page only to find that the page was already lock by a user (me). Does this mean that starting a new logged in session with the same user will not carry through session locks when checking the owner of a PageLock?

--AnonymousCoward, 14-Aug-2008


----

Is there any solution to this problem???

--AnonymousCoward, 20-Aug-2008


----

It would seem to make sense that all locks for a particular user should be released when they log off the site. This, however, is not the case...

--AnonymousCoward, 22-Sep-2008 17:53