Examples of ThemeSource


Examples of org.springframework.ui.context.ThemeSource

   * Determine the fallback theme for this context.
   * <p>The default implementation returns the default theme (with name "theme").
   * @return the fallback theme (never <code>null</code>)
   */
  protected Theme getFallbackTheme() {
    ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
    if (themeSource == null) {
      themeSource = new ResourceBundleThemeSource();
    }
    Theme theme = themeSource.getTheme(DEFAULT_THEME_NAME);
    if (theme == null) {
      throw new IllegalStateException("No theme defined and no fallback theme found");
    }
    return theme;
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * @return the current theme, or <code>null</code> if not found
   * @see #getThemeResolver
   */
  public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
      String themeName = themeResolver.resolveThemeName(request);
      return themeSource.getTheme(themeName);
    }
    else {
      return null;
    }
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * Determine the fallback theme for this context.
   * <p>The default implementation returns the default theme (with name "theme").
   * @return the fallback theme (never <code>null</code>)
   */
  protected Theme getFallbackTheme() {
    ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
    if (themeSource == null) {
      themeSource = new ResourceBundleThemeSource();
    }
    Theme theme = themeSource.getTheme(DEFAULT_THEME_NAME);
    if (theme == null) {
      throw new IllegalStateException("No theme defined and no fallback theme found");
    }
    return theme;
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * Determine the fallback theme for this context. <p>The default implementation returns the default theme (with name
   * "theme").
   * @return the fallback theme (never <code>null</code>)
   */
  protected Theme getFallbackTheme() {
    ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
    if (themeSource == null) {
      themeSource = new ResourceBundleThemeSource();
    }
    Theme theme = themeSource.getTheme(DEFAULT_THEME_NAME);
    if (theme == null) {
      throw new IllegalStateException("No theme defined and no fallback theme found");
    }
    return theme;
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * @return the current theme, or <code>null</code> if not found
   * @see #getThemeResolver
   */
  public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
      String themeName = themeResolver.resolveThemeName(request);
      return themeSource.getTheme(themeName);
    }
    else {
      return null;
    }
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * Determine the fallback theme for this context. <p>The default implementation returns the default theme (with name
   * "theme").
   * @return the fallback theme (never <code>null</code>)
   */
  protected Theme getFallbackTheme() {
    ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
    if (themeSource == null) {
      themeSource = new ResourceBundleThemeSource();
    }
    Theme theme = themeSource.getTheme(DEFAULT_THEME_NAME);
    if (theme == null) {
      throw new IllegalStateException("No theme defined and no fallback theme found");
    }
    return theme;
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * @return the current theme, or <code>null</code> if not found
   * @see #getThemeResolver
   */
  public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
      String themeName = themeResolver.resolveThemeName(request);
      return themeSource.getTheme(themeName);
    }
    else {
      return null;
    }
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * @return the initialized theme source (will never be <code>null</code>)
   * @see #THEME_SOURCE_BEAN_NAME
   */
  public static ThemeSource initThemeSource(ApplicationContext context) {
    if (context.containsLocalBean(THEME_SOURCE_BEAN_NAME)) {
      ThemeSource themeSource = context.getBean(THEME_SOURCE_BEAN_NAME, ThemeSource.class);
      // Make ThemeSource aware of parent ThemeSource.
      if (context.getParent() instanceof ThemeSource && themeSource instanceof HierarchicalThemeSource) {
        HierarchicalThemeSource hts = (HierarchicalThemeSource) themeSource;
        if (hts.getParentThemeSource() == null) {
          // Only set parent context as parent ThemeSource if no parent ThemeSource
          // registered already.
          hts.setParentThemeSource((ThemeSource) context.getParent());
        }
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Using ThemeSource [" + themeSource + "]");
      }
      return themeSource;
    }
    else {
      // Use default ThemeSource to be able to accept getTheme calls, either
      // delegating to parent context's default or to local ResourceBundleThemeSource.
      HierarchicalThemeSource themeSource = null;
      if (context.getParent() instanceof ThemeSource) {
        themeSource = new DelegatingThemeSource();
        themeSource.setParentThemeSource((ThemeSource) context.getParent());
      }
      else {
        themeSource = new ResourceBundleThemeSource();
      }
      if (logger.isDebugEnabled()) {
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * Determine the fallback theme for this context.
   * <p>The default implementation returns the default theme (with name "theme").
   * @return the fallback theme (never <code>null</code>)
   */
  protected Theme getFallbackTheme() {
    ThemeSource themeSource = RequestContextUtils.getThemeSource(getRequest());
    if (themeSource == null) {
      themeSource = new ResourceBundleThemeSource();
    }
    Theme theme = themeSource.getTheme(DEFAULT_THEME_NAME);
    if (theme == null) {
      throw new IllegalStateException("No theme defined and no fallback theme found");
    }
    return theme;
  }
View Full Code Here

Examples of org.springframework.ui.context.ThemeSource

   * @return the current theme, or <code>null</code> if not found
   * @see #getThemeResolver
   */
  public static Theme getTheme(HttpServletRequest request) {
    ThemeResolver themeResolver = getThemeResolver(request);
    ThemeSource themeSource = getThemeSource(request);
    if (themeResolver != null && themeSource != null) {
      String themeName = themeResolver.resolveThemeName(request);
      return themeSource.getTheme(themeName);
    }
    else {
      return null;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.