3 Replies Latest reply on Oct 27, 2008 5:02 PM by andre1001

    How to set the theme programatically

      Hi All,

      I need to display a user defined portlet on my portal page which will let the user select a theme from the dropdown and then the selected theme will be applied to the whole portal. Actually I am trying to set the default theme for portal. I am using the following code in my process action.

      //Get the Theme Service from the portlet context. Theme service is injected and saved in the context at start up.
       ThemeService themeService = (ThemeService) context.getAttribute("ThemeService");
      
       //themeName is a string which is the actual name of the theme. Will be the one that the user selects from the dropdown.
       PortalTheme themeToSet = themeService.getTheme(themeName, false);
       themeService.setDefault(themeToSet.getThemeInfo().getRegistrationId());



      The above code does not work and it does not set the default theme to the one I select from the dropdown. It does not throw any exception on the consone either. If I put a S.O.P after setting the default theme it still shows the earlier default name i.e
      renaissance
      .

      I am missing something somewhere. Could anyone help as I need to get this done as soon as possible.



      Any help is highly appreciated.

      Thanks and Regards,
      Milind Paranjape.


        • 1. Re: How to set the theme programatically

          I have found a partial solution to this problem.

          Portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, themeName);

          This changes the theme. The above line of code sets the theme across users. i.e for any and every user who logs in the portal the theme will be changed. This is not what I want.

          My requirement is when the user changes the theme it should be changed for that particular user itself and should not reflect for other users just as it happens in case of dashboard.

          Could any one out there help me resolve this problem?

          Appreciate if anyone from the JBoss portal team addresses this as I have a deadline to meet.

          • 2. Re: How to set the theme programatically

            Could anyone from the JBoss portal team care to help me? Its a little urgent.

            • 3. Re: How to set the theme programatically
              andre1001

              Hi,

              JBoss Portal 2.7.0 CR1.

              I have the same question, but I've noticed that it's possible to change the portal theme on a user basis using the dashboard area.

              Is it possible to change themes for regular portal objetcs like "admin" and "default" on a user basis?!?

              I've also noticed that users are children objects from dashboard object, but there's no users as children objects from "default" portal object, for example.

              Thanks for any help.