3 Replies Latest reply on Apr 2, 2007 10:46 AM by moldovan

    Richfaces components stop working when i activate own filter

    moldovan Newbie

      Hy Guys!

      After, i have tried the richfaces-components in a small selfmade application, I'm going to implement some components in my CRM-Webapp.

      But I have problems with a written filter of my webapp. This filter sets the character-encoding to needed UTF-8.
      - When my filter is activated, richfaces-components loose style and stop working.
      - When i comment out my filter in the web.xml, i get problems displaying and processing special characters of slovak language, because request-encoding ist setted to ISO.

      This is my filter:

      public class CharsetFilter implements Filter {
       private String encoding;
      
       /****************************************************************************
       * method: init() *
       * - this method overrides the init()-method from javax.servlet.Filter *
       * - set the encoding-var to UTF-8 *
       ****************************************************************************
       */
       public void init(FilterConfig config) throws ServletException {
       encoding = config.getInitParameter("requestEncoding");
      
       if (encoding == null)
       encoding = "UTF-8";
       }
      
       /****************************************************************************
       * method: doFilter() *
       * - this method overrides the init()-method from javax.servlet.Filter *
       * - filters the requests/response an set den Characterencoding to UTF-8 *
       ****************************************************************************
       */
       public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException
       {
       response.setContentType("text/html; charset=UTF-8");
       request.setCharacterEncoding(encoding);
      
       next.doFilter(request, response);
      
       response.setContentType("text/html; charset=UTF-8");
       request.setCharacterEncoding(encoding);
       }
      
       public void destroy() {
       }
      }


      Any ideas, how i can solve this problem?