protected String getJogetHeader() {
    String cp = request.getContextPath();
    String bn = ResourceBundleUtil.getMessage("build.number");
    String html =
        "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + cp
            + "/wro/common.css?build="
            + bn
            + "\" />\n"
            + "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + cp
            + "/wro/userview_v5.min.css?build="
            + bn
            + "\" />\n"
            + "<script type=\"text/javascript\" src=\""
            + cp
            + "/wro/common.js?build="
            + bn
            + "\"></script>\n"
            + "<script type=\"text/javascript\">\n";

    UserSecurity us = DirectoryUtil.getUserSecurity();
    if (!(us != null && us.getAllowSessionTimeout())) {
      html +=
          "$(document).ready(function(){\n"
              + "            $('body').append('<img id=\"image_alive\" style=\"display:none;\" width=\"1\" height=\"1\" src=\""
              + cp
              + "/images/v3/clear.gif?\" alt=\"\">');\n"
              + "            window.setInterval(\"keepMeAlive('image_alive')\", 200000);\n"
              + "        });\n"
              + "        function keepMeAlive(imgName)\n"
              + "        {  \n"
              + "             myImg = document.getElementById(imgName);   \n"
              + "             if (myImg)\n"
              + "                 myImg.src = myImg.src.replace(/\\?.*$/, '?' + Math.random());   \n"
              + "        }  ";
    }

    // fix IE browser
    html +=
        "if ($.browser.msie) {\n"
            + "            $(document).on(\"keydown\", function (e) {\n"
            + "                if (e.which === 8 && !$(e.target).is(\"input:not([readonly]), textarea:not([readonly])\")) {\n"
            + "                    e.preventDefault();\n"
            + "                }\n"
            + "            });\n"
            + "        }\n";

    // userview print feature
    html +=
        "function userviewPrint(){\n"
            + "            $('head').append('<link id=\"userview_print_css\" rel=\"stylesheet\" href=\""
            + cp
            + "/wro/userview_print.min.css\" type=\"text/css\" media=\"print\"/>');\n"
            + "            setTimeout(\"do_print()\", 1000); \n"
            + "        }\n"
            + "        function do_print(){\n"
            + "            window.print();\n"
            + "            $('#userview_print_css').remove();\n"
            + "        }\n";

    if ("true".equalsIgnoreCase(userview.getParamString("isPreview"))) {
      html +=
          "$(document).ready(function(){\n$('a').click(function(){\n"
              + "        var action = $(this).attr('href');\n"
              + "if (action !== \"\" && action !== undefined && action !== \"#\"){\n"
              + "        $('#preview').attr('action', action);\n"
              + "        $('#preview').submit();\n"
              + "}\n"
              + "        return false;\n"
              + "    });\n"
              + "\n});\n";
    }

    html +=
        "UI.base = \""
            + request.getContextPath()
            + "\";\n"
            + "        UI.userview_app_id = '"
            + userview.getParamString("appId")
            + "';\n"
            + "        UI.userview_id = '"
            + userview.getPropertyString("id")
            + "';\n";

    if (alertMessage != null && !alertMessage.isEmpty()) {
      html += "alert(\"" + alertMessage + "\");\n";
    }

    html += "</script>\n";

    html +=
        "    <script>\n"
            + "        ConnectionManager.tokenName = \""
            + SecurityUtil.getCsrfTokenName()
            + "\";\n"
            + "        ConnectionManager.tokenValue = \""
            + SecurityUtil.getCsrfTokenValue(request)
            + "\";\n"
            + "        JPopup.tokenName = \""
            + SecurityUtil.getCsrfTokenName()
            + "\";\n"
            + "        JPopup.tokenValue = \""
            + SecurityUtil.getCsrfTokenValue(request)
            + "\";\n"
            + "    </script>";

    return html;
  }
  public String getHtml() {
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("params", userview.getParams());
    data.put("userview", userview);
    data.put("is_login_page", isLoginPage);
    if (isLoginPage) {
      data.put("login_form_footer", DirectoryUtil.getLoginFormFooter());

      if (request.getSession() != null) {
        Throwable exception =
            (Throwable) request.getSession().getAttribute("SPRING_SECURITY_LAST_EXCEPTION");
        if (exception != null) {
          data.put("login_exception", exception.getMessage());
        }
      }
      data.put("login_error_classes", "form-errors alert alert-warning");
    }
    data.put("context_path", request.getContextPath());
    data.put("build_number", ResourceBundleUtil.getMessage("build.number"));
    String rightToLeft = WorkflowUtil.getSystemSetupValue("rightToLeft");
    data.put("right_to_left", "true".equalsIgnoreCase(rightToLeft));
    String locale = AppUtil.getAppLocale();
    data.put("locale", locale);
    data.put("embed", "true".equalsIgnoreCase(userview.getParamString("embed")));
    data.put("body_id", getBodyId());
    data.put("body_classes", getBodyClasses(rightToLeft, locale));
    data.put("base_link", request.getContextPath() + getBaseLink());
    data.put("home_page_link", request.getContextPath() + getHomePageLink());
    data.put("title", getTitle());
    data.put("hide_nav", false);
    data.put("nav_id", "navigation");
    data.put("nav_classes", "nav-collapse sidebar-nav");
    data.put("categories_container_id", "category-container");
    data.put("categories_container_classes", "nav nav-tabs nav-stacked main-menu");
    data.put("category_classes", "category");
    data.put("first_category_classes", "first");
    data.put("last_category_classes", "last");
    data.put("current_category_classes", "current-category active");
    data.put("combine_single_menu_category", false);
    data.put("menus_container_classes", "menu-container");
    data.put("menu_classes", "menu");
    data.put("first_menu_classes", "first");
    data.put("last_menu_classes", "last");
    data.put("current_menu_classes", "current active");
    data.put("main_container_id", "main");
    data.put("sidebar_id", "sidebar");
    data.put("content_id", "content");

    String username = WorkflowUtil.getCurrentUsername();
    boolean isLoggedIn = username != null && !WorkflowUserManager.ROLE_ANONYMOUS.equals(username);
    data.put("is_logged_in", isLoggedIn);
    if (isLoggedIn) {
      ExtDirectoryManager directoryManager =
          (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
      User user = directoryManager.getUserByUsername(username);
      data.put("username", username);
      data.put("user", user);
      data.put("logout_link", request.getContextPath() + "/j_spring_security_logout");
    } else {
      data.put("login_link", request.getContextPath() + getLoginLink());
    }

    data.put("content", getContent(data));

    String handleMenuResponse = handleMenuResponse();
    if (handleMenuResponse != null) {
      return handleMenuResponse;
    }

    data.put("metas", getMetas(data));
    data.put("joget_header", getJogetHeader());
    data.put("js_css_lib", getJsCssLib(data));
    data.put("fav_icon_link", getFavIconLink(data));
    data.put("js", getJs(data));
    data.put("css", getCss(data));
    data.put("head", getHead(data));
    if (!"true".equalsIgnoreCase(userview.getParamString("embed"))) {
      data.put("header", getHeader(data));
      if (isAuthorized) {
        data.put("menus", getMenus(data));
      }
      data.put("footer", getFooter(data));
    }
    data.put("joget_footer", getJogetFooter());
    data.put("content_container", getContentContainer(data));

    return getLayout(data);
  }