Пример #1
0
 /**
  * Returns the id of the currently active theme.
  *
  * @return the id of the current theme, never <code>null</code>
  */
 public static String getCurrentThemeId() {
   ThemeManager manager = ThemeManager.getInstance();
   ISessionStore session = ContextProvider.getSession();
   // 1) try URL parameter
   String result = ContextProvider.getRequest().getParameter(THEME_URL_PARM);
   if (result != null && manager.hasTheme(result)) {
     // TODO [rh] a method named get... should be constant, i.e. shouldn't
     //      have side-effects like altering session attributes
     session.setAttribute(CURR_THEME_ATTR, result);
   }
   // 2) try session attribute
   else {
     result = (String) session.getAttribute(CURR_THEME_ATTR);
   }
   // 3) use default
   if (result == null) {
     result = ThemeManager.DEFAULT_THEME_ID;
   }
   return result;
 }
Пример #2
0
 /**
  * Sets the current theme to the theme identified by the given id.
  *
  * @param themeId the id of the theme to activate
  * @throws IllegalArgumentException if no theme with the given id is registered
  */
 public static void setCurrentThemeId(final String themeId) {
   if (!ThemeManager.getInstance().hasTheme(themeId)) {
     throw new IllegalArgumentException("Illegal theme id: " + themeId);
   }
   ContextProvider.getSession().setAttribute(CURR_THEME_ATTR, themeId);
 }