0 Replies Latest reply on Feb 11, 2011 6:17 AM by lonny27

    Conversation depending richfaces skin

    lonny27

      Hallo,


      in my project (Seam + RichFaces) I need to change the RichFaces skin depending on a user input.
      This works fine, as long as the backing bean holding the current skin type is session scoped.
      But I need to change the skin only in the current conversation (a user may use the application in multiple browser windows, each showing the application using a different skin). Therefore I changed the backing bean to conversation scope.


      But that does not work! When RichFaces looks up the skin, new temporary conversations are opened and the default skin type of the newly created SkinState object is returned.


      The skin type is first set after login and when the user changes certain data.


      I added a debug output to SkinType#getSkin, which shows the following (manually commented) in the JBoss server log:


      #login page is loaded
      Conversation[null:3:DEFAULT]
      Conversation[null:3:DEFAULT]
      ...
      #login action, main page gets loaded
      Conversation[null:3:SKIN1]
      Conversation[null:3:SKIN1]
      Conversation[null:3:SKIN1]
      ...
      #at some point during the main page loading, new conversations are opened
      Conversation[null:4:DEFAULT]
      Conversation[null:5:DEFAULT]
      Conversation[null:6:DEFAULT]
      Conversation[null:4:DEFAULT]
      Conversation[null:6:DEFAULT]
      ...
      



      The resulting page is a mix of images from the SKIN1 skin and CSS files from the DEFAULT skin.


      Are conversation scoped skins not supported in Seam, or got I just the configuration wrong?


      Thanks in advance,
      Ron


      Seam 2.2.1.CR2, RichFaces 3.3.3.Final


      Configuration and backing bean:


      <!-- web.xml -->
      <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>#{skinState.skin}</param-value>
      </context-param>



      <!-- pages.xml -->
      <page view-id="/login.xhtml" login-required="false">
        <navigation>
          <rule if="#{identity.loggedIn}">
            <begin-conversation join="true" />
            <redirect view-id="/index.xhtml" />
          </rule>
        </navigation>
      </page>



      @Name("skinState")
      @Scope(ScopeType.CONVERSATION)
      @Synchronized
      public class SkinState implements Serializable {
        private SkinType skin = SkinType.DEFAULT; // the skin type when not logged in
      
        public void setSkin(SkinType skin) {
          this.skin = skin;
        }
      
        public String getSkin() {
          Conversation c = Conversation.instance();
          System.out.println("Conversation[" + c.getParentId() + ":" + c.getId() + ":" + skin + "]");
          return skin.name;
        }
      }