当前位置: 首页>>代码示例>>Java>>正文


Java ViewExpiredException类代码示例

本文整理汇总了Java中javax.faces.application.ViewExpiredException的典型用法代码示例。如果您正苦于以下问题:Java ViewExpiredException类的具体用法?Java ViewExpiredException怎么用?Java ViewExpiredException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ViewExpiredException类属于javax.faces.application包,在下文中一共展示了ViewExpiredException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFilter_SessionTimeoutRelogin

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Test
public void doFilter_SessionTimeoutRelogin() throws Exception {
    // given
    ServletException se = new ServletException(new ViewExpiredException());
    doThrow(se).when(authFilter).handleProtectedUrlAndChangePwdCase(
            eq(chainMock), any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock));
    doNothing().when(authFilter).reLogginUserIfRequired(
            any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock), any(StringBuffer.class));
    doReturn("admin").when(requestMock).getParameter(
            eq(AuthorizationFilter.PARAM_LOGIN_USER_ID));

    // when
    authFilter.doFilter(requestMock, responseMock, chainMock);

    // then
    verify(authFilter, times(1)).reLogginUserIfRequired(
            any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock), any(StringBuffer.class));
    verify(responseMock, times(1)).sendRedirect(anyString());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:AuthorizationFilterTest.java

示例2: doFilter_SessionTimeoutPublicAccess

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Test
public void doFilter_SessionTimeoutPublicAccess() throws Exception {
    // given
    ServletException se = new ServletException(new ViewExpiredException());
    doThrow(se).when(authFilter).handleProtectedUrlAndChangePwdCase(
            eq(chainMock), any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock));
    doNothing().when(authFilter).reLogginUserIfRequired(
            any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock), any(StringBuffer.class));

    // when
    authFilter.doFilter(requestMock, responseMock, chainMock);

    // then
    verify(authFilter, times(1)).reLogginUserIfRequired(
            any(HttpServletRequest.class), eq(responseMock),
            eq(authReqDataMock), any(StringBuffer.class));
    verify(responseMock, times(1)).sendRedirect(anyString());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:AuthorizationFilterTest.java

示例3: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            FacesContext fc = FacesContext.getCurrentInstance();
            NavigationHandler nav = fc.getApplication().getNavigationHandler();
            try {
                nav.handleNavigation(fc, null, "expired?faces-redirect=true&amp;includeViewParams=true");
                fc.renderResponse();
            } finally {
                i.remove();
            }
        }
    }
    // At this point, the queue will not contain any ViewExpiredEvents.
    // Therefore, let the parent handle them.
    getWrapped().handle();

}
 
开发者ID:drifted-in,项目名称:genopro-tools,代码行数:24,代码来源:ViewExpiredExceptionExceptionHandler.java

示例4: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            ViewExpiredException vee = (ViewExpiredException) t;
            FacesContext facesContext = FacesContext.getCurrentInstance();
            Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
            NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
            try {
                // Push some useful stuff to the request scope for use in the page
                requestMap.put("currentViewId", vee.getViewId());
                navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
                facesContext.renderResponse();
            } finally {
                i.remove();
            }
        }
    }

    // At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
    getWrapped().handle();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:27,代码来源:ViewExpiredExceptionExceptionHandler-template.java

示例5: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
	Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();

	while (events.hasNext()) {
		ExceptionQueuedEvent event = events.next();
		ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

		Throwable exception = context.getException();

		try {
			if (exception instanceof ViewExpiredException) {
                                   HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
                                   FacesContext.getCurrentInstance().getExternalContext().redirect(request.getRequestURI()+"?viewExpired=true");
			}
		} catch (IOException ex) {
                       Logger.getLogger(JsfExceptionHandler.class.getName()).log(Level.SEVERE, null, ex);
                   } finally {
			events.remove();
		}
	}

	getWrapped().handle();
}
 
开发者ID:dsalinux,项目名称:web-ifad,代码行数:25,代码来源:JsfExceptionHandler.java

示例6: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void handle() throws FacesException {
	FacesContext fc = FacesContext.getCurrentInstance();
	for ( Iterator<ExceptionQueuedEvent> i = this.getUnhandledExceptionQueuedEvents().iterator(); i.hasNext(); ) {
		ExceptionQueuedEvent event = i.next();
		ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
		Throwable t = context.getException();
		if ( fc.isProjectStage( ProjectStage.Development ) ) {
			t.printStackTrace();
		}
		do {
			if ( t instanceof AuthorizationException ) {
				this.handleAuthorizationException( fc, (AuthorizationException) t, i );
				return;
			}
			if ( t instanceof ViewExpiredException ) {
				this.handleViewExpiredException( fc, (ViewExpiredException) t, i );
				return;
			}
			t = t.getCause();
		} while ( t != null );
		this.handleGenericException( fc );
	}
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:28,代码来源:FacesExceptionHandler.java

示例7: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
    for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
        ExceptionQueuedEvent event = it.next();
        ExceptionQueuedEventContext eqec = event.getContext();
        
        if(eqec.getException() instanceof ViewExpiredException) {
            FacesContext context = eqec.getContext();
            if(!context.isReleased()) {
                NavigationHandler navHandler = context.getApplication().getNavigationHandler();
 
                try {
                    navHandler.handleNavigation(context, null, "home?faces-redirect=true&expired=true");
                }
                finally {
                    it.remove();
                }
            }
            
        }
    }

    this.wrapped.handle();
}
 
开发者ID:websphere,项目名称:PrimefacesShowcase,代码行数:26,代码来源:ShowcaseExceptionHandler.java

示例8: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
    for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
        ExceptionQueuedEvent event = it.next();
        ExceptionQueuedEventContext eqec = event.getContext();
        System.out.println("eqec.getException()"+eqec.getException());
        if(eqec.getException() instanceof ViewExpiredException || eqec.getException() instanceof AbortProcessingException) {
            FacesContext context = eqec.getContext();
            NavigationHandler navHandler = context.getApplication().getNavigationHandler();
 
            try {
                navHandler.handleNavigation(context, null, "main.xhtml?faces-redirect=true&expired=true");
            }
            catch(Exception e){
                System.out.println("exp"+e);
            }
            finally {
                it.remove();
            }
        }
    }

    this.wrapped.handle();;
}
 
开发者ID:wbstr,项目名称:liferay-newsletter,代码行数:26,代码来源:WcsExceptionHandler.java

示例9: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    LOG.log(Level.INFO, "invoking custom ExceptionHandlder...");
    Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();

    while (events.hasNext()) {
        ExceptionQueuedEvent event = events.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        LOG.log(Level.INFO, "[email protected]" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        //t.printStackTrace();
        if (t instanceof ViewExpiredException) {
            try {
                handleViewExpiredException((ViewExpiredException) t);
            } finally {
                events.remove();
            }
        } else if (t instanceof TaskNotFoundException) {
            try {
                handleNotFoundException((Exception) t);
            } finally {
                events.remove();
            }
        } else {

            getWrapped().handle();
        }
        LOG.log(Level.INFO, "ExceptionHandlder end.");
    }

}
 
开发者ID:hantsy,项目名称:javaee8-jsf-sample,代码行数:33,代码来源:DefaultExceptionHandler.java

示例10: handleViewExpiredException

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
开发者ID:hantsy,项目名称:javaee8-jsf-sample,代码行数:11,代码来源:DefaultExceptionHandler.java

示例11: doFilter

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
/**
 * Check if the current URL is protected and the current session doesn't
 * contain a user object. If this is the case perform a login.
 * 
 * The doFilter method of the Filter is called by the container each time a
 * request/response pair is passed through the chain due to a client request
 * for a resource at the end of the chain.
 * 
 * @throws IOException
 * @throws ServletException
 * 
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {

    HttpServletRequest httpRequest = new IgnoreCharacterEncodingHttpRequestWrapper(
            (HttpServletRequest) request);
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    AuthorizationRequestData rdo = initializeRequestDataObject(httpRequest);

    try {
        if (isPublicAccess(rdo, httpRequest)) {
            proceedWithFilterChain(chain, httpRequest, httpResponse);
        } else {
            handleProtectedUrlAndChangePwdCase(chain, httpRequest,
                    httpResponse, rdo);
        }
    } catch (ServletException e) {

        // relogin is not possible in this case,
        // no SAML response to extract userid and generate password.
        if (authSettings.isServiceProvider()) {
            throw e;
        }

        if (e.getCause() instanceof ViewExpiredException) {
            // if we were logged in but a logout occurs from a different
            // browser tab, we get this exception - so redirect to the
            // same page to stay on it (Bug 7552)
            final StringBuffer url = new StringBuffer(
                    rdo.getRelativePath() == null ? ""
                            : rdo.getRelativePath());
            reLogginUserIfRequired(httpRequest, httpResponse, rdo, url);
            sendRedirect(httpRequest, httpResponse, url.toString());
        } else {
            throw e;
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:51,代码来源:AuthorizationFilter.java

示例12: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    LOG.log(Level.INFO, "invoking custom ExceptionHandlder...");
    Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();

    while (events.hasNext()) {
        ExceptionQueuedEvent event = events.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        LOG.log(Level.INFO, "[email protected]" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesFileNotFoundException));
        t.printStackTrace();
        if (t instanceof ViewExpiredException) {
            try {
                handleViewExpiredException((ViewExpiredException) t);
            } finally {
                events.remove();
            }
        } else if (t instanceof FacesFileNotFoundException) {
            try {
                handleNotFoundException((Exception) t);
            } finally {
                events.remove();
            }
        } else {

            getWrapped().handle();
        }
        LOG.log(Level.INFO, "ExceptionHandlder end.");
    }

}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:35,代码来源:DefaultExceptionHandler.java

示例13: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    LOG.log(Level.INFO, "invoking custom ExceptionHandlder...");
    Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();

    while (events.hasNext()) {
        ExceptionQueuedEvent event = events.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        LOG.log(Level.INFO, "Exceptio[email protected]" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesFileNotFoundException));
        t.printStackTrace();
        if (t instanceof ViewExpiredException) {
            try {
                handleViewExpiredException((ViewExpiredException) t);
            } finally {
                events.remove();
            }
        } else if (t instanceof FacesFileNotFoundException) {
            try {
                handleNotFoundException((Exception) t);
            } finally {
                events.remove();
            }
        } else {

            getWrapped().handle();
        }
        LOG.log(Level.INFO, "ExceptionHandlder end.");
    }

}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:35,代码来源:DefaultExceptionHandler.java

示例14: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            ViewExpiredException vee = (ViewExpiredException) t;
            FacesContext fc = FacesContext.getCurrentInstance();
            Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
            NavigationHandler nav =
                    fc.getApplication().getNavigationHandler();
            try {
                // Push some useful stuff to the request scope for
                // use in the page
                requestMap.put("currentViewId", vee.getViewId());
 
                nav.handleNavigation(fc, null, "viewExpired");
                fc.renderResponse();
                RequestContext.getCurrentInstance().execute("PF('expiredSessionDialog').show();");
            } finally {
                i.remove();
            }
        }
    }
    // At this point, the queue will not contain any ViewExpiredEvents.
    // Therefore, let the parent handle them.
    getWrapped().handle();
 
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:31,代码来源:ViewExpiredExceptionExceptionHandler.java

示例15: handle

import javax.faces.application.ViewExpiredException; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            ViewExpiredException vee = (ViewExpiredException) t;
            LOG.log(Level.WARNING, "View Expired {0}", vee.getViewId());
            FacesContext fc = FacesContext.getCurrentInstance();
            NavigationHandler nav = fc.getApplication().getNavigationHandler();
            try {
                String navigation = vee.getViewId();
                if ("jobs/index.xhtml".equals(vee.getViewId())){
                    navigation += "?faces-redirect=true";
                }
                nav.handleNavigation(fc, null, navigation);
                fc.renderResponse();

            } finally {
                i.remove();
            }
        }
    }
    // At this point, the queue will not contain any ViewExpiredEvents.
    // Therefore, let the parent handle them.
    getWrapped().handle();

}
 
开发者ID:vodev,项目名称:vocloud,代码行数:30,代码来源:ViewExpiredExceptionHandler.java


注:本文中的javax.faces.application.ViewExpiredException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。