@Override public void setThemeName( HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable String themeName) { Assert.notNull(response, "HttpServletResponse is required for CookieThemeResolver"); if (StringUtils.hasText(themeName)) { // Set request attribute and add cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); addCookie(response, themeName); } else { // Set request attribute to fallback theme and remove cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, getDefaultThemeName()); removeCookie(response); } }
@Override public String resolveThemeName(HttpServletRequest request) { // Check request for preparsed or preset theme. String themeName = (String) request.getAttribute(THEME_REQUEST_ATTRIBUTE_NAME); if (themeName != null) { return themeName; } // Retrieve cookie value from request. String cookieName = getCookieName(); if (cookieName != null) { Cookie cookie = WebUtils.getCookie(request, cookieName); if (cookie != null) { String value = cookie.getValue(); if (StringUtils.hasText(value)) { themeName = value; } } } // Fall back to default theme. if (themeName == null) { themeName = getDefaultThemeName(); } request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); return themeName; }
public CookieThemeResolver() { setCookieName(DEFAULT_COOKIE_NAME); }
val cookieThemeResolver = new CookieThemeResolver(); cookieThemeResolver.setDefaultThemeName(defaultThemeName); cookieThemeResolver.setCookieDomain(tgc.getDomain()); cookieThemeResolver.setCookieHttpOnly(tgc.isHttpOnly()); cookieThemeResolver.setCookieMaxAge(tgc.getMaxAge()); cookieThemeResolver.setCookiePath(tgc.getPath()); cookieThemeResolver.setCookieSecure(tgc.isSecure());
@Bean(name = "themeResolver") public CookieThemeResolver cookieThemeResolver() { CookieThemeResolver cookieThemeResolver = new CookieThemeResolver(); cookieThemeResolver.setDefaultThemeName("default"); return cookieThemeResolver; }
@Test public void cookieThemeResolver() { internalTest(new CookieThemeResolver(), true, AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME); }
@Override public String resolveThemeName(HttpServletRequest request) { // Check request for preparsed or preset theme. String themeName = (String) request.getAttribute(THEME_REQUEST_ATTRIBUTE_NAME); if (themeName != null) { return themeName; } // Retrieve cookie value from request. Cookie cookie = WebUtils.getCookie(request, getCookieName()); if (cookie != null) { String value = cookie.getValue(); if (StringUtils.hasText(value)) { themeName = value; } } // Fall back to default theme. if (themeName == null) { themeName = getDefaultThemeName(); } request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); return themeName; }
@Override public String resolveThemeName(HttpServletRequest request) { String themeName = request.getParameter("theme"); return themeName == null ? super.resolveThemeName(request) : themeName; }
@Override public String resolveThemeName(HttpServletRequest request) { try { UserProfile userProfile = userBusinessService.getCurrentUserProfile(); if (userProfile != null) { return (userProfile.isHighContrastFacilitation() ? PORTAL_HIGH_CONTRAST_THEME : PORTAL_DEFAULT_THEME); } } catch (Exception e) { logger.warn(e, e); } return super.resolveThemeName(request); }
@Override public void setThemeName( HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable String themeName) { Assert.notNull(response, "HttpServletResponse is required for CookieThemeResolver"); if (StringUtils.hasText(themeName)) { // Set request attribute and add cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); addCookie(response, themeName); } else { // Set request attribute to fallback theme and remove cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, getDefaultThemeName()); removeCookie(response); } }
@Override public String resolveThemeName(HttpServletRequest request) { // Check request for preparsed or preset theme. String themeName = (String) request.getAttribute(THEME_REQUEST_ATTRIBUTE_NAME); if (themeName != null) { return themeName; } // Retrieve cookie value from request. String cookieName = getCookieName(); if (cookieName != null) { Cookie cookie = WebUtils.getCookie(request, cookieName); if (cookie != null) { String value = cookie.getValue(); if (StringUtils.hasText(value)) { themeName = value; } } } // Fall back to default theme. if (themeName == null) { themeName = getDefaultThemeName(); } request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); return themeName; }
public CookieThemeResolver() { setCookieName(DEFAULT_COOKIE_NAME); }
@Override public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName) { if (StringUtils.hasText(themeName)) { // Set request attribute and add cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, themeName); addCookie(response, themeName); } else { // Set request attribute to fallback theme and remove cookie. request.setAttribute(THEME_REQUEST_ATTRIBUTE_NAME, getDefaultThemeName()); removeCookie(response); } }
public CookieThemeResolver() { setCookieName(DEFAULT_COOKIE_NAME); }