本文整理汇总了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);
}
}
示例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&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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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 );
}
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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();;
}
示例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.");
}
}
示例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.");
}
}
示例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();
}