0

上の特定のビューに移動する必要があるカスタム例外ハンドラーを作成しましたViewExpiredException

ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();

if (t instanceof ViewExpiredException) {
    ViewExpiredException v = (ViewExpiredException) t;
    FacesContext fc = FacesContext.getCurrentInstance();
    Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
    NavigationHandler nav = fc.getApplication().getNavigationHandler();

    try {
        requestMap.put("currentViewId", v.getViewId());
        nav.handleNavigation(fc, "*", "viewExpired"+"?faces-redirect=true");
        fc.renderResponse();

ただし、次の例外が行にスローされますnav.handleNavigation()

 java.lang.NullPointerException
    at org.apache.myfaces.application.NavigationHandlerImpl.getNavigationCase(NavigationHandlerImpl.java:203)
    at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:77)
    at com.daimler.esr.ui.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:55)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:191)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)

MyFaces と PrimFaces 3.4 を使用しています。

4

1 に答える 1

0

の "from" を指定しないで"*"、代わりに にしnullます。

nav.handleNavigation(fc, null, "viewExpired?faces-redirect=true");

"from" 以外を指定するとnull、関連付けられた "from" を見つけるために現在のビュー ID を特定する必要がありますが、これは のようなワイルドカードです"*"。現在のビューの有効期限が切れているため ( を取得しましたViewExpiredExceptionよね?)、もう使用できませNullPointerExceptioncontext.getViewRoot().getViewId()

于 2013-04-05T14:37:09.350 に答える