4 Replies Latest reply on Mar 31, 2008 11:54 AM by Sergey Smirnov

    Skinnability per user session

    Patrick Madden Newbie

      Hi,

      I see how to change the skin by using web.xml. However I'm looking for a way to change the skin per http session rather than per servlet context.

      I'm not interested in creating my own skin but just to use the prebuilt ones. I see the SkinBean object in the demo but I don't understand how that gets hooked into the rendering phase.

      I want to be able to do something like setSkin("deepMarine") but only have it affect a single users session.

      I'm sure its possible just don't know how ;)

      Thanks,

      PVM

        • 1. Re: Skinnability per user session
          Roberto Morales Newbie

          create a skin bean that contain a property where you can put the name of selected skin by the client and in web.xml put something like that

          This example asume that skin bean have a property of type string named skin

          <context-param>
           <param-name>org.ajax4jsf.SKIN</param-name>
           <param-value>#{skinBean.skin}</param-value>
           </context-param>
          


          your skin bean have to be defined in the faces config

           <managed-bean>
           <managed-bean-name>skinBean</managed-bean-name>
           <managed-bean-class>yourpackage.SkinBean</managed-bean-class>
           <managed-bean-scope>session</managed-bean-scope>
           </managed-bean>
          


          define the bean in session scope in faces-config.xml and when the user change the skin you only will need change the property value in the defined skin bean.

          You can create an action in the skin bean that will be executed by the apply button and set the selected skin in the skin property of you bean


          • 2. Re: Skinnability per user session
            Patrick Madden Newbie

            Thank You!

            Works great and very simple.

            PVM

            • 3. Re: Skinnability per user session
              Adi Katz Novice

              The RichFaces framework calls the setSkin(..) method and passes in the strin "DEFAULT" each time a new session starts...
              which make the app starts always wth the default skin.
              Any way to avoid that ?

              Another thing I noticed when running it through a debbuger is that getSkin method is called lots of times for each request.
              I wonder why that is.

              • 4. Re: Skinnability per user session
                Sergey Smirnov Master

                I do not understand why you believe that skin is attached to the session. It is not. If you use EL in the web.xml to point to the managed bean, its setters and getters will be invoked the same way as any other managed bean getters and setters. Managed bean used as a skin bean is nothing more than the regular managed bean.