function SessionKeepAlive(linkElementId) {
        var instance = this;
        this.timeToNextCheckInMs = 100; // Make first check after 100 ms.
        this.xmlHttpReq = new XMLHttpRequest();
        var linkComponent = document.getElementById(linkElementId);
        if (linkComponent) {
            this.link = linkComponent.getAttribute("href");
        }
        this.xmlHttpReq.onreadystatechange = function() {
            if (instance.xmlHttpReq.readyState == 4) {
                if (instance.xmlHttpReq.status == 200) {
                    instance.timeToNextCheckInMs = instance.xmlHttpReq.responseText;
                    window.setTimeout(instance.poll, instance.timeToNextCheckInMs);
            	} else {
                    console.log("SessionKeepAlive failed with HTTP status code " + instance.xmlHttpReq.status);
            	}
            }
        };
        this.poll = function() {
        	instance.xmlHttpReq.open("GET", instance.link, true);
            try {
            	instance.xmlHttpReq.send();
            } catch (exception) {
                console.log("SessionKeepAlive failed: " + exception);
            }
        };
        if (this.link) {
        	window.setTimeout(this.poll, this.timeToNextCheckInMs);
        } else {
            console.log("Unable to find link element with ID '" + linkElementId + "'. SessionKeepAlive will not be enabled.");
        }
    }
/**
     * Keep JSF session alive by polling back-end before the session has expired.
     * 
     * @param linkElementId ID of a-element pointing to keep alive link.
     */
Keep JSF session alive by polling back-end before the session has expired.

@param linkElementId ID of a-element pointing to keep alive link.
Keep JSF session alive by polling back - end before the session has expired . @param linkElementId ID of a - element pointing to keep alive link .
function SessionKeepAlive(linkElementId) {
        var instance = this;
        this.timeToNextCheckInMs = 100; 
        this.xmlHttpReq = new XMLHttpRequest();
        var linkComponent = document.getElementById(linkElementId);
        if (linkComponent) {
            this.link = linkComponent.getAttribute("href");
        }
        this.xmlHttpReq.onreadystatechange = function() {
            if (instance.xmlHttpReq.readyState == 4) {
                if (instance.xmlHttpReq.status == 200) {
                    instance.timeToNextCheckInMs = instance.xmlHttpReq.responseText;
                    window.setTimeout(instance.poll, instance.timeToNextCheckInMs);
            	} else {
                    console.log("SessionKeepAlive failed with HTTP status code " + instance.xmlHttpReq.status);
            	}
            }
        };
        this.poll = function() {
        	instance.xmlHttpReq.open("GET", instance.link, true);
            try {
            	instance.xmlHttpReq.send();
            } catch (exception) {
                console.log("SessionKeepAlive failed: " + exception);
            }
        };
        if (this.link) {
        	window.setTimeout(this.poll, this.timeToNextCheckInMs);
        } else {
            console.log("Unable to find link element with ID '" + linkElementId + "'. SessionKeepAlive will not be enabled.");
        }
    }
function SessionKeepAlive ( linkElementId ) { var instance = this ; this . timeToNextCheckInMs = 100 ; this . xmlHttpReq = new XMLHttpRequest ( ) ; var linkComponent = document . getElementById ( linkElementId ) ; if ( linkComponent ) { this . link = linkComponent . getAttribute ( "href" ) ; } this . xmlHttpReq . onreadystatechange = function ( ) { if ( instance . xmlHttpReq . readyState == 4 ) { if ( instance . xmlHttpReq . status == 200 ) { instance . timeToNextCheckInMs = instance . xmlHttpReq . responseText ; window . setTimeout ( instance . poll , instance . timeToNextCheckInMs ) ; } else { console . log ( "SessionKeepAlive failed with HTTP status code " + instance . xmlHttpReq . status ) ; } } } ; this . poll = function ( ) { instance . xmlHttpReq . open ( "GET" , instance . link , true ) ; try { instance . xmlHttpReq . send ( ) ; } catch ( exception ) { console . log ( "SessionKeepAlive failed: " + exception ) ; } } ; if ( this . link ) { window . setTimeout ( this . poll , this . timeToNextCheckInMs ) ; } else { console . log ( "Unable to find link element with ID '" + linkElementId + "'. SessionKeepAlive will not be enabled." ) ; } }
Keep JSF session alive by polling back-end before the session has expired.
Keep JSF session alive by polling back - end before the session has expired .
// Make first check after 100 ms.