2 Replies Latest reply on Nov 25, 2006 3:05 PM by William E. Sollers III

    Theme / Locale / TZ not persistent

    William E. Sollers III Newbie

      The cookies emitted when the user selects one of the ui customization selectors expire when the browser is closed. That means that when the user logs back into the app in another session the preferences are lost.

      The problem is this code in the XXXSelector
      public void select()
      {
      Contexts.removeFromAllContexts( Seam.getComponentName(Theme.class) );
      FacesContext facesContext = FacesContext.getCurrentInstance();
      String viewId = facesContext.getViewRoot().getViewId();
      UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);
      facesContext.setViewRoot(viewRoot);
      if (cookieEnabled)
      {
      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
      response.addCookie( new Cookie("org.jboss.seam.core.Theme", theme) );
      }
      }


      I modded it to :

      public void select()
      {
      Contexts.removeFromAllContexts( Seam.getComponentName(Theme.class) );
      FacesContext facesContext = FacesContext.getCurrentInstance();
      String viewId = facesContext.getViewRoot().getViewId();
      UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);
      facesContext.setViewRoot(viewRoot);
      if (cookieEnabled)
      {
      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
      Cookie cookie = new Cookie("org.jboss.seam.core.Theme", theme);
      cookie.setMaxAge ( 31536000 );
      response.addCookie( cookie );
      }
      }

      Now when I go into a new session the cookie is picked up and used and all my settings are okay.