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


Java ExceptionQueuedEvent类代码示例

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


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

示例1: handleException

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
/**
 * @param context
 * @throws Throwable
 */
private void handleException(FacesContext context) {
    Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents = getUnhandledExceptionQueuedEvents().iterator();

    if (unhandledExceptionQueuedEvents.hasNext()) {
        Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException();
        unhandledExceptionQueuedEvents.remove();

        Throwable rootCause = Exceptions.unwrap(exception);

        if (rootCause instanceof BusinessException) {
            handleBusinessException(context, (BusinessException) rootCause);
            return;
        }

        //send user to error page when unexpected exceptions are raised
        goToErrorPage(context, rootCause);
    }

}
 
开发者ID:adminfaces,项目名称:admin-template,代码行数:24,代码来源:CustomExceptionHandler.java

示例2: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例3: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例4: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例5: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
/**
 *
 * @throws FacesException
 */
@Override
public void handle() throws FacesException {

    final Iterator<ExceptionQueuedEvent> unhandledExceptionQueuedEvents
            = getUnhandledExceptionQueuedEvents().iterator();

    if (unhandledExceptionQueuedEvents.hasNext()) {

        final Throwable exception = unhandledExceptionQueuedEvents
                .next()
                .getContext()
                .getException();

        unhandledExceptionQueuedEvents.remove();

        final Throwable rootCause = this.unwrap(exception);

        this.showError(rootCause.getMessage());
        
        return;
    }
    this.wrapped.handle();
}
 
开发者ID:arthurgregorio,项目名称:exemplos,代码行数:28,代码来源:CustomExceptionHandler.java

示例6: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    final Iterator iterator = getUnhandledExceptionQueuedEvents().iterator();
    while (iterator.hasNext()) {
        final ExceptionQueuedEvent event = (ExceptionQueuedEvent) iterator.next();
        final ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        final Throwable throwable = context.getException();
        final FacesContext fc = FacesContext.getCurrentInstance();
        final ValueExpression valueExpression = fc.getApplication().getExpressionFactory()
                .createValueExpression(fc.getELContext(), "#{delegatesInjector}", DelegatesInjector.class);
        final DelegatesInjector delegatesInjector = (DelegatesInjector) valueExpression.getValue(fc.getELContext());
        final Map<Class, ExceptionHandlerDelegate> delegatesMap = delegatesInjector.getDelegatesMap();
        try {
            if (delegateHandling(throwable, delegatesMap, fc)) {
                iterator.remove();
            } else {
                getWrapped().handle();
            }
        } catch (IOException e) {
            LOGGER.error("error while handling exception: " + throwable, e);
            getWrapped().handle();
        }
    }
}
 
开发者ID:noveogroup,项目名称:clap,代码行数:25,代码来源:DelegatingExceptionHandler.java

示例7: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();

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

        Throwable t = context.getException();
        final FacesContext fc = FacesContext.getCurrentInstance();
        final ExternalContext externalContext = fc.getExternalContext();
        final ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler();
        try {
            log.error(t.getMessage(), t);
            performRedirect(externalContext, "/error_service");
            fc.renderResponse();
        } finally {
            i.remove();
        }
    }
    getWrapped().handle();
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:22,代码来源:GlobalExceptionHandler.java

示例8: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例9: handleExceptionMsgPage

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
/**
 * Handle an exception with just redirects to an error page with a message
 * 
 * @param i
 *            iterator to remove from on success
 * @param facelet
 *            JSF view to redirect to
 * @param msg
 *            message to display
 */
private void handleExceptionMsgPage( FacesContext fc, Iterator<ExceptionQueuedEvent> i, String facelet, String msg ) {

	NavigationHandler nav = fc.getApplication().getNavigationHandler();
	try {
		final String msgKey = RandomPassword.getPassword( 10 );
		Object sessionObj = fc.getExternalContext().getSession( true );
		if ( sessionObj instanceof HttpSession ) {
			((HttpSession) sessionObj).setAttribute( msgKey, msg );
		}

		nav.handleNavigation( fc, null, facelet + "?msgKey=" + msgKey + "&faces-redirect=true" );
		fc.renderResponse();
	}
	catch ( Exception eee ) {
	}
	finally {
		if ( i != null ) {
			i.remove();
		}
	}
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:32,代码来源:FacesExceptionHandler.java

示例10: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例11: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    for (final Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator(); it.hasNext();) {
        Throwable throwable = it.next().getContext().getException();
        logger.error("Caught an unexpected exception", throwable);

        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();

        Map<String, Object> sessionMap = externalContext.getSessionMap();
        sessionMap.put("errorDetails", ExceptionPrettyPrinter.prettyPrint(throwable));
        sessionMap.put("errorToken", UUID.randomUUID().toString());

        try {
            String url = externalContext.getRequestContextPath() + "/faces/errors/error.xhtml";
            externalContext.redirect(url);
        } catch (Exception ex) {
            logger.error("Could not redirect user to error page", ex);
        } finally {
            it.remove();
        }
    }

    getWrapped().handle();
}
 
开发者ID:satrapu,项目名称:home-budget,代码行数:26,代码来源:ExceptionHandler.java

示例12: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例13: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例14: handle

import javax.faces.event.ExceptionQueuedEvent; //导入依赖的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

示例15: handle

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

     if (unhandledExceptionQueuedEvents.hasNext()) {
         Throwable exception = unhandledExceptionQueuedEvents.next().getContext().getException();
         MessageUtil.getInstance().error(exception);
     }
     super.handle();
 }
 
开发者ID:ddRPB,项目名称:rpb,代码行数:11,代码来源:RpbExceptionHandler.java


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