2013-07-10 3 views
0

세션을 검사하는 필터가 있습니다. 내 필터 :세션이 만료 된 후 Primefaces 구성 요소가 응답하지 않습니다.

public class FilterLogin implements Filter{ 

    FilterConfig fc; 

    @Override 
    public void init(FilterConfig filterConfig) throws ServletException { 
     //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
     fc = filterConfig; 
    } 

    @Override 
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { 
     //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 

     HttpServletRequest req = (HttpServletRequest) request; 
     HttpServletResponse resp = (HttpServletResponse) response; 
     HttpSession session = req.getSession(true); 

     if (session.getAttribute("loginMB") == null) { 
      resp.sendRedirect("/home.xhtml"); 
     } else { 
      chain.doFilter(request, response); 
     } 
    } 

    @Override 
    public void destroy() { 
     //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 
    } 

} 

의 web.xml은 :

<filter> 
    <filter-name>filter</filter-name> 
    <filter-class>pl.ePrzychodnia.filter.LoginFilter</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>filter</filter-name> 
    <url-pattern>/protected/*</url-pattern> 
</filter-mapping> 
<error-page> 
    <exception-type>javax.faces.application.ViewExpiredException</exception-type> 
    <location>/home.xhtml</location> 
</error-page> 

세션이 만료 될 때 나는 사이트 home.xhtml로 이동합니다. 하지만 세션이 만료되고 페이지의 탐색 메뉴를 클릭하면 구성 요소가 클릭에 반응하지 않습니다. Primefaces를 사용하지 않으면 모든 것이 올바르게 작동합니다. 내 프로젝트에서 primefaces를 사용할 때이 오류가 발생합니다. 그 원인은 무엇일까요?

나는 전역 예외 처리기를 사용하려고하지만 약간 문제가있다. 이 사이트 http://wmarkito.wordpress.com/2012/04/05/adding-global-exception-handling-using-jsf-2-x-exceptionhandler/

에서 클래스를 복사 클래스 CustomExceptionHandler 편집 : 나는 변경

try { 

       //log error ? 
       log.log(Level.SEVERE, "Critical Exception!", t); 

       //redirect error page 
       requestMap.put("exceptionMessage", t.getMessage()); 
       nav.handleNavigation(fc, null, "/home"); 
       fc.renderResponse(); 

       // remove the comment below if you want to report the error in a jsf error message 
       //JsfUtil.addErrorMessage(t.getMessage()); 

      } 

: nav.handleNavigation(fc, null, "/error");

nav.handleNavigation(fc, null, "/home");에 그러나 세션 시간 제한 내가 페이지를 home.xhtml하는 reditect하지 않을 경우에만 이동 클릭하면 예제 오류가 발생했습니다.

SEVERE: Critical Exception! 
javax.faces.application.ViewExpiredException: viewId:/protected/admin/about.xhtml - View /protected/admin/about.xhtml could not be restored. 

내가 abou 내 세션이 만료되었을 때 t 페이지. 불완전한 about.xhtml 페이지가 home.xhtml이 표시됩니다.

+0

당신이 오류 메시지를지고의 FullAjaxExceptionHandler 기능을 사용할 수 있습니까? 어떤 주요면과 JSF 버전? – Andy

+0

primefaces [idleMonitor] (http://www.primefaces.org/showcase/ui/idlemonitorHome.jsf)를 시도 할 수 있습니다. – landal79

+0

멈추는 위치에 xhtml 부분을 게시하십시오. – Andy

답변

1

아마도 관리 대상 Bean에 대한 ajax 호출을 작성했을 것입니다. 이것이 웹 XML에서 오류 탐색이 작동하지 않는 이유입니다. 액션이 ajax 요청으로 호출되면 오류는 JavaScript 콜백 onerror으로 전송됩니다.

서버 측에서 오류를 처리하려면 응용 프로그램에 전역 예외 처리기를 추가 할 수 있습니다. Adding global exception handling using JSF 자습서는 따라야 할 좋은 안내서입니다.

또한, 당신은 OmniFaces

+0

나는 당신이 틀렸다는 것을 말하는 것이 아닙니다. 나는 앞으로 비슷한 문제가 생길 때를 대비하여 대답을 이해하려고 노력하고 있습니다. 그래서 나처럼 들리는다면 용서해주세요. 'onerror' 함수는'ajax' 요청에 문제가있을 때 호출됩니다? 이것은 네비게이션과 어떤 관련이 있습니까? 설명해 주시겠습니까? – Andy

+0

오, 기다려라. 나는 그것을 얻는다 : – Andy

+0

나는 첫 번째 방법으로 전역 예외 handlinb를 사용하지만, 나는 약간의 문제가있다. 나는 첫 번째 게시물을 편집했다. –

관련 문제