Bill F
Bill F

Reputation: 2087

Keep Session Active script how to turn it on and off

I got this script block from OpenNTF:

<xp:div id="keepSessionAlive"></xp:div>
<xp:scriptBlock id="scriptBlock1">
    <xp:this.value>
    <![CDATA[   
        XSP.addOnLoad(function(){
            setInterval(function(){
                XSP.partialRefreshPost("#{id:keepSessionAlive}", {});   
            }, 3000000)
        })]]>
    </xp:this.value>
</xp:scriptBlock>

I have added it to a control that displays a document. What I want to do is enable this script block from an edit button that toggles the document to EditMode, then turn it off when the document is saved. ie I only want the session to remain active if a document is being edited otherwise allow the Application Time Out settings to take place. If I set a sessionScope variable to 0 or say 3000000 in the edit button and use that in place of the 3000000 in the code would that do it, but I think that would immediately time the session out. Or ???

Upvotes: 0

Views: 118

Answers (2)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

There's also the Keep Session Alive Extension Library control, which does the same. That uses a partialRefreshGet.

Upvotes: 1

Howard
Howard

Reputation: 1503

How about only load this script block when the document is in edit mode (loaded property?)

Howard

Upvotes: 2

Related Questions