1 Reply Latest reply on Sep 18, 2009 12:30 PM by Julien Kronegg

    Initializing a seam component from a filter

    Meissa Sakho Newbie

      Hi all,
      I need to initialize the ThemeSelector component from my filter like below(extract):


      public void doFilter(ServletRequest aRequest, ServletResponse aResponse, FilterChain aFilterChain) throws IOException, ServletException {
          
                  ThemeSelector.instance().setTheme("themeBPInternet");
      }
      


      While running the webapp,Im getting the exception below.


      Exception during request processing:
      Caused by java.lang.IllegalStateException with message: No active session context
      org.jboss.seam.theme.ThemeSelector.instance(ThemeSelector.java:193)
      com.natixis.sphinx.security.myReroutage.ReroutageProcessingFilter.afterUnmarshal(ReroutageProcessingFilter.java:35)
      com.natixis.sphinx.security.reroutage.ReroutageProcessingFilter.doFilter(ReroutageProcessingFilter.java:268)
      org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)


      I've corrected it using a the code below:




      public void doFilter(ServletRequest aRequest, ServletResponse aResponse, FilterChain aFilterChain) throws IOException, ServletException {
      
          new ContextualHttpServletRequest((HttpServletRequest) aRequest) {
      
              public void process() {
      
                  ThemeSelector.instance().setTheme("themeBPInternet");
      
              }
      
          }.run();
      
      aFilterChain.doFilter(aRequest, aResponse);
      
      }
      
      



      I would like to know if there is a simpliest way to call the ThemeSelector.instance().


      thank in advance.


      Meissa