| Customizing GWC-JS applications / How Do I … ? | |
The MySessionEndWidget widget, provided as part of the default customization, allows you to specify a redirection URL.
The MySessionEndWidget customization extends the SessionEndWidget to automatically redirect the user to a specified URL after a set number of milliseconds.
Edit MySessionEndWidget.js to change the redirect URL or the delay before redirection. Comments in the widget identify where these changes can be made.
// update redirection link url of the template
var redirectionLink = this._element.getElementsByClassName("redirectionLink")[0];
redirectionLink.title = i18n.t("mycusto.session.redirectionText");
var url = "http://www.google.com";
redirectionLink.href = url;
var modelHelper = new cls.ModelHelper(this);
// Launch the redirection after a delay of 10 seconds
// To remove the delay, remove the setTimeout, but keep the 'if' block
setTimeout(function () {
    // check if an application is running in the current session before reloading
    if(!modelHelper.getCurrentApplication()) {
        window.location = url;
    }
}.bind(this), 10000); // 10000ms
To
eliminate the delay, remove the setTimeout function code surrounding
window.location = url:var modelHelper = new cls.ModelHelper(this);
    // check if an application is running in the current session before reloading
    if(!modelHelper.getCurrentApplication()) {
        window.location = url;
    }
The message displayed prior to the redirection is based on the value of the redirectionText variable in the language-specific .json files, located in the locales directory of the customization project. To update the message, edit each of the language-specific files.
After making any changes to a widget file, rebuild your customization project using the grunt command.