8 Replies Latest reply: Sep 23, 2008 8:04 PM by 633131 RSS

    set skin per user

    633131
      Hello,

      I'l trying to set personalized skin (per user) in 11g TP4. So far I did the following:

      * trinidad-skins.xml set the skins
      * trinidad-config.xml
      bq. bq. {color:#008000}<?xml version="1.0" encoding="windows-1252"?>{color} \\ {color:#008000}<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">{color} \\ {color:#008000} <skin-family>#{sessionScope.skinFamily eq null ? 'myskinfamily' : sessionScope.skinFamily }</skin-family>{color} \\ {color:#008000}</trinidad-config>{color}

      * backing bean:

      for initial load:

      bq. bq. {color:#008000} public void BeforePhase(PhaseEvent phaseEvent){color} \\ {color:#008000} {{color} \\ {color:#008000} // Add event code here...{color} \\ {color:#008000} if (phaseEvent.getPhaseId().getOrdinal() == 6){color} \\ {color:#008000} {{color} \\ {color:#008000} if (!isPostback()){color} \\ {color:#008000} {{color} \\ {color:#008000} FacesContext ctx = FacesContext.getCurrentInstance();{color} \\ {color:#008000} Map sessionState = ctx.getExternalContext().getSessionMap();{color} \\ {color:#008000} sessionState.put("skinFamily", "myskinfamily_green"); \\ // TODO modify the personalized default skin \\ {color} \\ {color:#008000} }{color} \\ {color:#008000} }{color}

           {color:#008000} }{color}
           and runtime change via menu

      bq. {color:#008000} public void defaultThemeMenu_AL(ActionEvent actionEvent) \\ throws Throwable \\ { \\ FacesContext ctx = FacesContext.getCurrentInstance(); \\ Map sessionState = ctx.getExternalContext().getSessionMap(); \\ sessionState.put("skinFamily", "myskinfamily"); \\ }{color} \\ {color:#008000} public void greenThemeMenu_AL(ActionEvent actionEvent) \\ { \\ FacesContext ctx = FacesContext.getCurrentInstance(); \\ Map sessionState = ctx.getExternalContext().getSessionMap(); \\ sessionState.put("skinFamily", "myskinfamily_green");{color} \\ My issue is that i cannot set the skin that will be used at the first page load (BeforePhase). Changing the skins after page load (from the menu using defaultThemeMenu_AL and greenThemeMenu_AL) is working fine. \\ Where should I put the code for the skin loaded initially? \\ Thanks, \\ Viorel
        • 1. Re: set skin per user
          PaKo
          Hi!

          You should simplify your code:

          Use session scoped bcking bean (e.g. myUserSetting bean) with some attribute e.g. skin to store skin per user with accessors like this:

          private String _skin;
          public String getSkin() {
          if(_skin==null) {
          _skin = getSomehowSkinForUser(userId);
          }
          return _skin;
          }
          public setSkin(String newSkin) {
          _skin = newSkin;
          }

          Then, in trinidad-config.xml, use:
          <skin-family>#{myUserSetting.skin}</skin-family>

          An on page, you can use:

          <af:selectOneChoice label="Skin" value="#{myUserSetting.skin}">
          <af:selectItem label="Skin 1" value="SKIN1"/>
          <af:selectItem label="Skin 2" value="SKIN2"/>
          </af:selectOneChoice>

          Regards,
          PaKo
          • 2. Re: set skin per user
            Frank Nimphius-Oracle
            Hi,

            yu need to re-direct the request after applying a new skin. So in your phase listener you set a new skin but its to late and a skin is applied already

            Frank
            • 3. Re: set skin per user
              633131
              Thanks a lot PaKo and Frank.
              Everything is working fine now.
              The initial skin to load was set in the backing bean like this:
              public class selectedSkin_class
              {

              // private String skinFamily = "myskinfamilygreen";
              public String _skinFamily;
              public username_class username;

              public selectedSkin_class()
              {
              username = new username_class();
              OperationBinding ob = ADFUtils.findOperation("ConfigUsers_ExecuteWithParams");
              ob.getParamsMap().put("username", username.userName.toString());
              ob.execute();
              _skinFamily = (String) ADFUtils.findControlBinding("SkinName").getInputValue();
              // _skinFamily = "myskinfamily_green";
              }

              public String getSkinFamily()
              {
              return _skinFamily;
              }

              public void setSkinFamily(String family)
              {
              _skinFamily = family;
              }

              }

              Appreciate your help
              Vio
              • 4. Re: set skin per user
                633131
                One more question please: how to redirect the request (to the same page) after changing the skin in the backing bean?
                I tried with partial triggers but is not working
                • 5. Re: set skin per user
                  PaKo
                  Use:

                  FacesContext.getCurrentInstance().setViewRoot(newViewRoot);

                  where newViewRoot is the redirect page (or the current ViewRoot if you just want to refresh current page!).
                  • 6. Re: set skin per user
                    633131
                    thanks a lot. Vio
                    • 7. Re: set skin per user
                      PaKo
                      You could award some answer points...
                      • 8. Re: set skin per user
                        633131
                        Sorry.