List of usage examples for org.springframework.web.servlet.support RequestContextUtils getThemeSource
@Nullable public static ThemeSource getThemeSource(HttpServletRequest request)
From source file:org.dspace.webmvc.view.freemarker.SpringThemeAwareFreemarkerConfiguration.java
@Override public Template getTemplate(String name, Locale locale, String encoding, boolean parse) throws IOException { String themePath = SpringThemeContextUtils.getProperty("theme.template.path"); // If we have a theme path, attempt locating the template within the theme first if (themePath != null) { try {/*w ww . j av a 2 s.c om*/ return super.getTemplate(themePath + name, locale, encoding, parse); } catch (IOException ioe) { // Will throw an exception if there is no template in the theme path, // we will ignore it, and try the standard path locations } } String themeParentName = SpringThemeContextUtils.getProperty("theme.parent", null); if (!StringUtils.isEmpty(themeParentName)) { RequestAttributes ra = RequestContextHolder.currentRequestAttributes(); if (ra instanceof ServletRequestAttributes) { ServletRequestAttributes sra = (ServletRequestAttributes) ra; ThemeSource ts = RequestContextUtils.getThemeSource(sra.getRequest()); if (ts != null) { Theme parentTheme = ts.getTheme(themeParentName); while (parentTheme != null) { themePath = SpringThemeUtils.getProperty(parentTheme, "theme.template.path", locale, null); if (themePath != null) { try { return super.getTemplate(themePath + name, locale, encoding, parse); } catch (IOException ioe) { // Will throw an exception if there is no template in the theme path, // we will ignore it, and try the standard path locations } } themeParentName = SpringThemeUtils.getProperty(parentTheme, "theme.parent", locale, null); parentTheme = ts.getTheme(themeParentName); } } } } // No template in the theme path, so get a template from the standard location return super.getTemplate(name, locale, encoding, parse); }
From source file:jetx.ext.springmvc.SpringMvcFunctions.java
/** * ?ThemeSource // ww w .j a va 2 s .c o m */ public static ThemeSource getThemeSource(JetPageContext ctx) { HttpServletRequest request = ExtendUtils.getHttpServletRequest(ctx); return RequestContextUtils.getThemeSource(request); }