2 Replies Latest reply on Feb 13, 2009 7:11 AM by Binesh Gummadi

    Changing theme dynamically

    Binesh Gummadi Novice

      Is there a way to intercept and change theme dynamically?

      Scenario is user belongs to an organization and each organization has a theme and based on user organization I want to set the theme.

      Is this doable?

        • 1. Re: Changing theme dynamically
          Burkhard Vogt Newbie

          we did it by using a custom:


          which determines the users theme and provides it into the request:
          serverInvocation.getServerContext().getClientRequest().setAttribute(ATTR_VIEW_THEME, theme);

          and a custom:

          which reads the theme out of the request:
           PageContext pageContext = (PageContext) getJspContext();
           HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
           PortalTheme theme = (PortalTheme) request.getAttribute(PageCustomizerInterceptor.ATTR_VIEW_THEME);

          and writes its elements onto the page:
          JspWriter outWriter = pageContext.getOut();
          Iterator it = theme.getElements().iterator();
          while (it.hasNext())
           ThemeElement te = (ThemeElement) it.next();
           String elementString = te.getElement();

          • 2. Re: Changing theme dynamically
            Binesh Gummadi Novice

            Thank you. This is what I am looking for and will try this approach.