Java Code Examples for javax.faces.event.ExceptionQueuedEvent#getSource()

The following examples show how to use javax.faces.event.ExceptionQueuedEvent#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalExceptionHandler.java    From oxAuth with MIT License 6 votes vote down vote up
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();
        try {
if (isInvalidSessionStateException(t)) {
             log.error(t.getMessage(), t);
	performRedirect(externalContext, "/error_session.htm");
} else {
             log.error(t.getMessage(), t);
             performRedirect(externalContext, "/error_service.htm");
}
            fc.renderResponse();
        } finally {
            i.remove();
        }
    }
    getWrapped().handle();
}
 
Example 2
Source File: ViewExpiredExceptionExceptionHandler.java    From journaldev with MIT License 6 votes vote down vote up
@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();
}
 
Example 3
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 4
Source File: DefaultExceptionHandler.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
public void handle() throws FacesException {
	log.debug("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.debug("Exception@" + t);
        log.debug("ExceptionHandlder began.");
        log.debug("t instanceof FacesException@" + (t instanceof FacesException));
        log.debug("t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException));
        if (t instanceof ViewExpiredException) {
            try {
                handleViewExpiredException((ViewExpiredException) t);
            } finally {
                events.remove();
            }
        }

        if (t instanceof FacesFileNotFoundException|| t instanceof TaskNotFoundException) {
            try {
                handleNotFoundException((Exception) t);
            } finally {
                events.remove();
            }
        }
        log.debug("ExceptionHandlder end.");
        getWrapped().handle();
    }
    

}
 
Example 5
Source File: DefaultExceptionHandler.java    From ee7-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t);
        log.log(Level.INFO, "ExceptionHandlder began.");
        log.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
     //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (t instanceof FacesFileNotFoundException));
        if (t instanceof ViewExpiredException) {
            try {
                handleViewExpiredException((ViewExpiredException) t);
            } finally {
                events.remove();
            }
        }

        if (t instanceof FacesFileNotFoundException || t instanceof TaskNotFoundException) {
            try {
                handleNotFoundException((Exception) t);
            } finally {
                events.remove();
            }
        }
        log.log(Level.INFO, "ExceptionHandlder end.");
        getWrapped().handle();
    }

}
 
Example 6
Source File: GlobalExceptionHandler.java    From oxTrust with MIT License 5 votes vote down vote up
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();
        try {
if (isSecurityException(t)) {
	performRedirect(externalContext, "/login.htm");
} else if (isConversationException(t)) {
	log.trace(t.getMessage(), t);
	performRedirect(externalContext, "/conversation_error.htm");
} if (isViewExpiredException(t)) {
                storeRequestURI();
                performRedirect(externalContext, "/login.htm");
} else {
	log.trace(t.getMessage(), t);
	performRedirect(externalContext, "/error.htm");
}
            fc.renderResponse();
        } finally {
            i.remove();
        }
    }
    getWrapped().handle();
}
 
Example 7
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 8
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 9
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 10
Source File: CustomExceptionHandler.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
    while (i.hasNext()) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        // get the exception from context
        Throwable t = context.getException();

        FacesContext facesContext = FacesContext.getCurrentInstance();

        if (t instanceof ViewExpiredException) {
            try {

                String homeLocation = "/index.xhtml";
                facesContext.setViewRoot(facesContext.getApplication().getViewHandler().createView(facesContext, homeLocation));
                facesContext.getPartialViewContext().setRenderAll(true);
                String messageText = "Your session is expired and data is resetted.";
                FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageText, messageText);
                facesContext.addMessage(null, message);
                facesContext.renderResponse();

            } finally {
                //remove it from queue
                i.remove();
            }
        }
    }
    //parent handle
    getWrapped().handle();
}
 
Example 11
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 12
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 13
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 14
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 15
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 16
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 17
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@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, "Exception@" + t.getClass().getName());
        LOG.log(Level.INFO, "ExceptionHandlder began.");
        LOG.log(Level.INFO, "t instanceof FacesException@" + (t instanceof FacesException));
        //   log.log(Level.INFO, "t instanceof FacesFileNotFoundException@" + (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.");
    }

}
 
Example 18
Source File: DefaultExceptionHandler.java    From javaee8-jsf-sample with GNU General Public License v3.0 5 votes vote down vote up
@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, "Exception@" + 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.");
    }

}