assertWindowId : function()

in deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js [333:411]


            assertWindowId : function() {
                var jfwid = dswh.utils.getUrlParameter(window.location.href, 'jfwid');

                dswh.utils.log('--- #assertWindowId');
                dswh.utils.log('jfwid: ' + jfwid);

                // window name is defined -> existing tab
                if (dswh.utils.isWindowNameDefined()) {

                    // is the current window name a already managed by DS?
                    if (dswh.utils.isManagedWindowName()) {

                        var windowId = dswh.utils.getWindowIdFromWindowName();

                        // we triggered the windowId recreation last request
                        if (windowId === dswh.TEMP_WINDOW_NAME) {
                            // enabled initial redirect
                            // -> use the new windowId from the url
                            if (jfwid) {
                                dswh.utils.log('assign window name from request parameter');

                                dswh.utils.setWindowIdAsWindowName(jfwid);
                            }
                            // disabled initial redirect
                            // -> use the new windowId from the rendered config as no url param is available
                            else {
                                dswh.utils.log('assign window name from server windowId');

                                dswh.utils.setWindowIdAsWindowName(dswh.windowId);
                            }
                        }
                        // security check like on the server side
                        else if (windowId.length > dswh.maxWindowIdLength) {
                            dswh.utils.log('window id from window name exeeds maxWindowIdLength - request new windowId');

                            dswh.utils.requestNewWindowId();
                        }
                        // window name doesn't match requested windowId
                        // -> redirect to the same view with current windowId from the window name
                        else if (windowId !== jfwid) {
                            dswh.utils.log('reload url with window name');

                            window.location = dswh.utils.setUrlParam(window.location.href, 'jfwid', windowId);
                        }
                    }
                    else {
                        dswh.utils.log('window name is unmanaged - request new windowId');

                        dswh.utils.requestNewWindowId();
                    }
                }
                // window name is undefined -> "open in new tab/window" was used
                else {
                    // url param available?
                    if (jfwid) {
                        // initial redirect
                        // -> the windowId is valid - we don't need to a second request
                        if (dswh.cfg.initialRedirectWindowId && jfwid === dswh.cfg.initialRedirectWindowId) {
                            dswh.utils.log('assign window name from initialRedirectWindowId');

                            dswh.utils.setWindowIdAsWindowName(dswh.cfg.initialRedirectWindowId);
                        }
                        // != initial redirect
                        // -> request a new windowId to avoid multiple tabs with the same windowId
                        else {
                            dswh.utils.log('request new windowId');

                            dswh.utils.requestNewWindowId();
                        }
                    }
                    // as no url parameter is available, the request is a new tab with disabled initial redirect
                    // -> just use the windowId from the renderer
                    else if (dswh.windowId) {
                        dswh.utils.log('assign window name from server windowId');

                        dswh.utils.setWindowIdAsWindowName(dswh.windowId);
                    }
                }
            },