3 Replies Latest reply on Aug 11, 2008 4:54 AM by Ilya Shaikovsky

    problem with richfaces+JSF filter

    João Longo Newbie

      Hello people, the loading page doesn't show richfaces style and I can't do login. If I don't put the filter, it's all right, but I need the filter!


      my web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      
       <display-name>a4jEchoText</display-name>
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <listener>
       <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
       </listener>
      
       <filter>
       <filter-name>MainFilter</filter-name>
       <filter-class>controller.MainFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>MainFilter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
      
      
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>false</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
       <session-config>
       <session-timeout>
       30
       </session-timeout>
       </session-config>
       <welcome-file-list>
       <welcome-file>faces/index.jsp</welcome-file>
       </welcome-file-list>
      </web-app>


      filter
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      
      package controller;
      
      import java.io.IOException;
      import javax.servlet.Filter;
      import javax.servlet.FilterChain;
      import javax.servlet.FilterConfig;
      import javax.servlet.RequestDispatcher;
      import javax.servlet.ServletException;
      import javax.servlet.ServletRequest;
      import javax.servlet.ServletResponse;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      import vo.UsuarioVO;
      
      /**
       *
       * @author joaosavio
       */
      
      //Filtro de autenticação
      public class MainFilter implements Filter {
       public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
       HttpServletRequest hreq = (HttpServletRequest)req;
       HttpServletResponse hres = (HttpServletResponse)res;
       UsuarioVO usuarioVO = new UsuarioVO();
       usuarioVO = (UsuarioVO) hreq.getSession().getAttribute("usuarioVO");
      
       if(usuarioVO != null) {
       chain.doFilter(req,res);
       }
       else {
       RequestDispatcher rd = req.getRequestDispatcher("/faces/index.jsp");
       rd.forward(hreq,hres);
       }
      
       }
      
       public void init(FilterConfig arg0) {
       }
      
       public void destroy() {
      
       }
      }
      


      Help me!