public static String calculateViewId(FacesContext context) {
        Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
        String viewId = (String) requestMap.get("jakarta.servlet.include.path_info");

        if (viewId == null) {
            viewId = context.getExternalContext().getRequestPathInfo();
        }

        if (viewId == null) {
            viewId = (String) requestMap.get("jakarta.servlet.include.servlet_path");
        }

        if (viewId == null) {
            viewId = context.getExternalContext().getRequestServletPath();
        }

        return viewId;
    }
Calculates the current viewId - we can't get it from the ViewRoot if it's not available.

@param context The {@link FacesContext}.
@return The current viewId.
primefaces/src/main/java/org/primefaces/util/ComponentUtils.java