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

    Changing theme dynamically

      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
          bvogt

          we did it by using a custom:

          org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor

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

          and a custom:
          org.jboss.portal.theme.tag.ThemeTagHandler

          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();
          
          ...
          
           outWriter.println(elementString);
          }
          ...


          • 2. Re: Changing theme dynamically

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