Package javax.faces.event

Examples of javax.faces.event.ExceptionQueuedEventContext


            }
           
            catch (Throwable e)
            {
                // JSF 2.0: publish the executor's exception (if any).
                ExceptionQueuedEventContext context = new ExceptionQueuedEventContext (
                    facesContext, e, null, PhaseId.RENDER_RESPONSE);
                facesContext.getApplication().publishEvent (facesContext, ExceptionQueuedEvent.class, context);
            }
           
            finally
View Full Code Here


            // create an UpdateModelException and enqueue it since
            // we are not allowed to throw it directly here
            // spec javadoc: The exception must not be re-thrown. This enables tree traversal to
            // continue for this lifecycle phase, as in all the other lifecycle phases.
            UpdateModelException updateModelException = new UpdateModelException(facesMessage, e);
            ExceptionQueuedEventContext exceptionQueuedContext
                    = new ExceptionQueuedEventContext(context, updateModelException, this, PhaseId.UPDATE_MODEL_VALUES);
           
            // spec javadoc says we should call context.getExceptionHandler().processEvent(exceptionQueuedContext),
            // which is not just syntactically wrong, but also stupid!!
            context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, exceptionQueuedContext);
           
View Full Code Here

                // because user can handle it in custom exception handler then.
                if (ape != null)
                {
                    e = ape;
                }
                ExceptionQueuedEventContext exceptionContext
                        = new ExceptionQueuedEventContext(context, e, source, context.getCurrentPhaseId());
                context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, exceptionContext);

               
                if (ape != null)
                {
View Full Code Here

            }
           
            catch (Throwable e)
            {
                // JSF 2.0: publish the executor's exception (if any).
                ExceptionQueuedEventContext context = new ExceptionQueuedEventContext (
                    facesContext, e, null, PhaseId.RENDER_RESPONSE);
                facesContext.getApplication().publishEvent (facesContext, ExceptionQueuedEvent.class, context);
            }
           
            finally
View Full Code Here

        return _phaseListenerList.toArray(new PhaseListener[_phaseListenerList.size()]);
    }
   
    private void publishException (Throwable e, PhaseId phaseId, FacesContext facesContext)
    {
        ExceptionQueuedEventContext context = new ExceptionQueuedEventContext (facesContext, e, null, phaseId);
       
        facesContext.getApplication().publishEvent (facesContext, ExceptionQueuedEvent.class, context);
    }
View Full Code Here

                    // get the event to handle
                    ExceptionQueuedEvent event = unhandled.peek();
                    try
                    {
                        // call its getContext() method
                        ExceptionQueuedEventContext context = event.getContext();
                       
                        // and call getException() on the returned result
                        Throwable exception = context.getException();

                        // spec described behaviour of PreJsf2ExceptionHandler

                        // UpdateModelException needs special treatment here
                        if (exception instanceof UpdateModelException)
                        {
                            FacesMessage message = ((UpdateModelException) exception).getFacesMessage();
                            // Log a SEVERE message to the log
                            log.log(Level.SEVERE, message.getSummary(), exception.getCause());
                            // queue the FacesMessage on the FacesContext
                            UIComponent component = context.getComponent();
                            String clientId = null;
                            if (component != null)
                            {
                                clientId = component.getClientId(context.getContext());
                            }
                            context.getContext().addMessage(clientId, message);
                        }
                        else if (!shouldSkip(exception) && !context.inBeforePhase() && !context.inAfterPhase())
                        {
                            // set handledAndThrown so that getHandledExceptionQueuedEvent() returns this event
                            handledAndThrown = event;

                            // Re-wrap toThrow in a ServletException or
                            // (PortletException, if in a portlet environment)
                            // and throw it
                            // FIXME: The spec says to NOT use a FacesException
                            // to propagate the exception, but I see
                            //        no other way as ServletException is not a RuntimeException
                            toThrow = wrap(getRethrownException(exception));
                            break;
                        }
                        else
                        {
                            // Testing mojarra it logs a message and the exception
                            // however, this behaviour is not mentioned in the spec
                            log.log(Level.SEVERE, exception.getClass().getName() + " occured while processing " +
                                    (context.inBeforePhase() ? "beforePhase() of " :
                                            (context.inAfterPhase() ? "afterPhase() of " : "")) +
                                    "phase " + context.getPhaseId() + ": " +
                                    "UIComponent-ClientId=" +
                                    (context.getComponent() != null ?
                                            context.getComponent().getClientId(context.getContext()) : "") + ", " +
                                    "Message=" + exception.getMessage());

                            log.log(Level.SEVERE, exception.getMessage(), exception);
                        }
                    }
View Full Code Here

            }
           
            catch (Throwable e)
            {
                // JSF 2.0: publish the executor's exception (if any).
                ExceptionQueuedEventContext context = new ExceptionQueuedEventContext (
                    facesContext, e, null, PhaseId.RENDER_RESPONSE);
                facesContext.getApplication().publishEvent (facesContext, ExceptionQueuedEvent.class, context);
            }
           
            finally
View Full Code Here

        lazyInit();
        Iterator<ExceptionQueuedEvent> exceptionQueuedEventIterator = getUnhandledExceptionQueuedEvents().iterator();

        while (exceptionQueuedEventIterator.hasNext())
        {
            ExceptionQueuedEventContext exceptionQueuedEventContext =
                    (ExceptionQueuedEventContext) exceptionQueuedEventIterator.next().getSource();

            @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
            Throwable throwable = exceptionQueuedEventContext.getException();

            String viewId = null;

            if (throwable instanceof ViewExpiredException)
            {
                viewId = ((ViewExpiredException) throwable).getViewId();
            }
            else if(throwable instanceof ContextNotActiveException)
            {
                FacesContext facesContext = exceptionQueuedEventContext.getContext();
                Flash flash =  facesContext.getExternalContext().getFlash();

                //the error page uses a cdi scope which isn't active as well
                if(flash.containsKey(ContextNotActiveException.class.getName()))
                {
                    break;
                }

                if(facesContext.getViewRoot() != null)
                {
                    viewId = facesContext.getViewRoot().getViewId();
                }
            }

            if(viewId != null)
            {
                FacesContext facesContext = exceptionQueuedEventContext.getContext();
                UIViewRoot uiViewRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId);

                if (uiViewRoot == null)
                {
                    continue;
View Full Code Here

                // get the event to handle
                ExceptionQueuedEvent event = unhandled.peek();
                try
                {
                    // call its getContext() method
                    ExceptionQueuedEventContext context = event.getContext();
                   
                    // and call getException() on the returned result
                    Throwable exception = context.getException();
                   
                    // Upon encountering the first such Exception that is not an instance of
                    // javax.faces.event.AbortProcessingException
                    if (!shouldSkip(exception))
                    {
                        // set handledAndThrown so that getHandledExceptionQueuedEvent() returns this event
                        handledAndThrown = event;
                       
                        // Re-wrap toThrow in a ServletException or (PortletException, if in a portlet environment)
                        // and throw it
                        // FIXME: The spec says to NOT use a FacesException to propagate the exception, but I see
                        //        no other way as ServletException is not a RuntimeException
                        toThrow = wrap(getRethrownException(exception));
                        break;
                    }
                    else
                    {
                        // Testing mojarra it logs a message and the exception
                        // however, this behaviour is not mentioned in the spec
                        log.log(Level.SEVERE, exception.getClass().getName() + " occured while processing " +
                                (context.inBeforePhase() ? "beforePhase() of " :
                                        (context.inAfterPhase() ? "afterPhase() of " : "")) +
                                "phase " + context.getPhaseId() + ": " +
                                "UIComponent-ClientId=" +
                                (context.getComponent() != null ?
                                        context.getComponent().getClientId(context.getContext()) : "") + ", " +
                                "Message=" + exception.getMessage());
                       
                        log.log(Level.SEVERE, exception.getMessage(), exception);
                       
                    }
View Full Code Here

                // get the event to handle
                ExceptionQueuedEvent event = unhandled.peek();
                try
                {
                    // call its getContext() method
                    ExceptionQueuedEventContext context = event.getContext();

                    if (facesContext == null)
                    {
                        facesContext = event.getContext().getContext();
                    }
                   
                    // and call getException() on the returned result
                    Throwable exception = context.getException();
                   
                    // Upon encountering the first such Exception that is not an instance of
                    // javax.faces.event.AbortProcessingException
                    if (!shouldSkip(exception))
                    {
                        // set handledAndThrown so that getHandledExceptionQueuedEvent() returns this event
                        handledAndThrown = event;
                       
                        Throwable rootCause = getRootCause(exception);
                       
                        throwableList.add(rootCause == null ? exception : rootCause);
                       
                        //break;
                    }
                    else
                    {
                        // Testing mojarra it logs a message and the exception
                        // however, this behaviour is not mentioned in the spec
                        log.log(Level.SEVERE, exception.getClass().getName() + " occured while processing " +
                                (context.inBeforePhase() ? "beforePhase() of " :
                                        (context.inAfterPhase() ? "afterPhase() of " : "")) +
                                "phase " + context.getPhaseId() + ": " +
                                "UIComponent-ClientId=" +
                                (context.getComponent() != null ?
                                        context.getComponent().getClientId(context.getContext()) : "") + ", " +
                                "Message=" + exception.getMessage());
                       
                        log.log(Level.SEVERE, exception.getMessage(), exception);
                    }
                }
View Full Code Here

TOP

Related Classes of javax.faces.event.ExceptionQueuedEventContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.