protected String constructInitialRedirectUrl(FacesContext context) {
        ExternalContext externalContext = context.getExternalContext();

        String url = externalContext.getRequestContextPath() + externalContext.getRequestServletPath();
        if (externalContext.getRequestPathInfo() != null) {
            url += externalContext.getRequestPathInfo();
        }

        Map<String, List<String>> parameters = new HashMap<>();
        for (Map.Entry<String, String[]> entry : externalContext.getRequestParameterValuesMap().entrySet()) {
            List<String> values = parameters.computeIfAbsent(entry.getKey(), k -> new ArrayList<>(1));
            if (entry.getValue() != null) {
                values.addAll(Arrays.asList(entry.getValue()));
            }
        }
        parameters.put(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, Arrays.asList(id));

        url = appendParameters(externalContext, url, parameters);

        // use servlet if available to avoid resource push
        if (externalContext.getResponse() instanceof HttpServletResponse) {
            url = ((HttpServletResponse) externalContext.getResponse()).encodeURL(url);
        }
        else {
            //only #encodeResourceURL is portable currently, maybe Portlet doesnt implement resource push
            url = externalContext.encodeResourceURL(url);
        }

        return url;
    }
Constructs the URL for the initialRedirect, which equals the current requested URL + the window id candidate.
We cant use
{@link jakarta.faces.application.ViewHandler#getBookmarkableURL(jakarta.faces.context.FacesContext, java.lang.String, java.util.Map, boolean)}
as the ViewRoot isn't available yet in the {@link FacesContext}.
Same applies for {@link ExternalContext#encodeRedirectURL(java.lang.String, java.util.Map)}.

@param context The {@link FacesContext}.
@return The initial-redirect URL.
primefaces/src/main/java/org/primefaces/clientwindow/PrimeClientWindow.java