@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { String newTheme = request.getParameter(this.paramName); if (newTheme != null) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request); if (themeResolver == null) { throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?"); } themeResolver.setThemeName(request, response, newTheme); } // Proceed in any case. return true; }
/** * Change the current theme to the specified theme by name, * storing the new theme name through the configured {@link ThemeResolver}. * @param themeName the name of the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(String themeName) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, themeName); // Ask for re-resolution on next getTheme call. this.theme = null; }
/** * Change the current theme to the specified one, * storing the new theme name through the configured {@link ThemeResolver}. * @param theme the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(@Nullable Theme theme) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, (theme != null ? theme.getName() : null)); this.theme = theme; }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { String newTheme = request.getParameter(this.paramName); if (newTheme != null) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request); if (themeResolver == null) { throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?"); } themeResolver.setThemeName(request, response, newTheme); } // Proceed in any case. return true; }
/** * Change the current theme to the specified theme by name, * storing the new theme name through the configured {@link ThemeResolver}. * @param themeName the name of the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(String themeName) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, themeName); // Ask for re-resolution on next getTheme call. this.theme = null; }
/** * Change the current theme to the specified one, * storing the new theme name through the configured {@link ThemeResolver}. * @param theme the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(@Nullable Theme theme) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, (theme != null ? theme.getName() : null)); this.theme = theme; }
private void internalTest(ThemeResolver themeResolver, boolean shouldSet, String defaultName) { // create mocks MockServletContext context = new MockServletContext(); MockHttpServletRequest request = new MockHttpServletRequest(context); MockHttpServletResponse response = new MockHttpServletResponse(); // check original theme String themeName = themeResolver.resolveThemeName(request); assertEquals(themeName, defaultName); // set new theme name try { themeResolver.setThemeName(request, response, TEST_THEME_NAME); if (!shouldSet) fail("should not be able to set Theme name"); // check new theme namelocale themeName = themeResolver.resolveThemeName(request); assertEquals(TEST_THEME_NAME, themeName); themeResolver.setThemeName(request, response, null); themeName = themeResolver.resolveThemeName(request); assertEquals(themeName, defaultName); } catch (UnsupportedOperationException ex) { if (shouldSet) fail("should be able to set Theme name"); } }
@Override public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName) { themeName = StringUtils.hasText(themeName) ? themeName : defaultTheme; for (ThemeResolver themeResolver : themeResolvers) { themeResolver.setThemeName(request, response, themeName); } }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { String newTheme = request.getParameter(this.paramName); if (newTheme != null) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request); if (themeResolver == null) { throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?"); } themeResolver.setThemeName(request, response, newTheme); } // Proceed in any case. return true; }
/** * Change the current theme to the specified theme by name, * storing the new theme name through the configured {@link ThemeResolver}. * @param themeName the name of the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(String themeName) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, themeName); // Ask for re-resolution on next getTheme call. this.theme = null; }
/** * Change the current theme to the specified one, * storing the new theme name through the configured {@link ThemeResolver}. * @param theme the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(Theme theme) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, (theme != null ? theme.getName() : null)); this.theme = theme; }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { String newTheme = request.getParameter(getParamName()); if (newTheme != null) { ThemeResolver themeResolver = cookieThemeResolver(); if (themeResolver != null) { themeResolver.setThemeName(request, response, newTheme); } } return true; } };
/** * Change the current theme to the specified one, * storing the new theme name through the configured {@link ThemeResolver}. * @param theme the new theme * @see ThemeResolver#setThemeName */ public void changeTheme(@Nullable Theme theme) { ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(this.request); if (themeResolver == null) { throw new IllegalStateException("Cannot change theme if no ThemeResolver configured"); } themeResolver.setThemeName(this.request, this.response, (theme != null ? theme.getName() : null)); this.theme = theme; }
@Override public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName) { if (isNested()) { for (ThemeResolver localeResolver : getResolvers()) { localeResolver.setThemeName(request, response, themeName); } } }
public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName) { ThemeResolver themeResolver = RequestInstanceHolder .getMappingInstance().getCommonThemeResolver(); if (themeResolver != null) { logger.logMessage(LogLevel.DEBUG, " invoke themeResolver.setThemeName() method that will proxy [" + themeResolver + "]"); themeResolver.setThemeName(request, response, themeName); } }
themeResolver.setThemeName(request, response, newTheme);
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { Locale locale = localeResolver.resolveLocale(request); userSettingsHolder.setLocale(locale); localeResolver.setLocale(request, response, locale); String themeName = themeResolver.resolveThemeName(request); userSettingsHolder.setTheme(themeName); themeResolver.setThemeName(request, response, themeName); final String timezone = timezoneResolver.resolveSetting(request); userSettingsHolder.setTimezone(timezone); timezoneResolver.setSetting(timezone); }