Package javax.faces.event

Examples of javax.faces.event.ExceptionQueuedEventContext


          VisitContext.createVisitContext(facesContext));
      facesContext.getViewRoot().visitTree(visitContext, new PostRestoreStateEventVisitCallback());
    }
    catch (AbortProcessingException e) {
      PhaseId phaseId = facesContext.getCurrentPhaseId();
      ExceptionQueuedEventContext eventContext = new ExceptionQueuedEventContext(facesContext, e, null, phaseId);
      facesContext.getApplication().publishEvent(facesContext, ExceptionQueuedEvent.class, eventContext);
    }
    finally {
      facesContext.getAttributes().remove(attributeName);
    }
View Full Code Here


            // look for and invoke any listeners not specific to the source class
            invokeListenersFor(systemEventClass, event, source, null, false);
        } catch (AbortProcessingException ape) {
            context.getApplication().publishEvent(context,
                                                  ExceptionQueuedEvent.class,
                                                  new ExceptionQueuedEventContext(context, ape));
        }

    }
View Full Code Here

    @SuppressWarnings({"ThrowableInstanceNeverThrown"})
    public void handle() throws FacesException {

        for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext(); ) {
            ExceptionQueuedEvent event = i.next();
            ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
            try {
                Throwable t = context.getException();
                if (isRethrown(t)) {
                    handled = event;
                    Throwable unwrapped = getRootCause(t);
                    if (unwrapped != null) {
                        throwIt(context.getContext(),
                                new FacesException(unwrapped.getMessage(), unwrapped));
                    } else {
                        if (t instanceof FacesException) {
                            throwIt(context.getContext(), (FacesException) t);
                        } else {
                            throwIt(context.getContext(),
                                    new FacesException(t.getMessage(), t));
                        }
                    }
                } else {
                    log(context);
View Full Code Here

                source.broadcast(event);
            }
            catch (AbortProcessingException e)
            {
                // publish the Exception to be handled by the ExceptionHandler
                ExceptionQueuedEventContext exceptionContext
                        = new ExceptionQueuedEventContext(context, e, source, context.getCurrentPhaseId());
                context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, exceptionContext);
               
                // Abortion
                eventsAborted.add(event);
            }
View Full Code Here

    @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();
                NavigationHandler navHandler = context.getApplication().getNavigationHandler();
                try {
                    navHandler.handleNavigation(context, null, "welcome.jsf?faces-redirect=true&expired=true");
                }
View Full Code Here

    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 NavigationHandler nav = fc.getApplication().getNavigationHandler();

            try {
View Full Code Here

    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 NavigationHandler nav = fc.getApplication().getNavigationHandler();

            try {
View Full Code Here

            // look for and invoke any listeners not specific to the source class
            invokeListenersFor(systemEventClass, event, source, null, false);
        } catch (AbortProcessingException ape) {
            context.getApplication().publishEvent(context,
                                                  ExceptionQueuedEvent.class,
                                                  new ExceptionQueuedEventContext(context, ape));
        }

    }
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();
                       
                        if (errorHandlerClass != null)
                        {
                            // myfaces-1.2's error handler
                            try
                            {
                                Class<?> clazz = Class.forName(errorHandlerClass);

                                Object errorHandler = clazz.newInstance();

                                Method m = clazz.getMethod("handleException",
                                                           new Class[] { FacesContext.class, Exception.class });
                                m.invoke(errorHandler, new Object[] { context.getContext(), exception });
                            }
                            catch (ClassNotFoundException ex)
                            {
                                throw new FacesException("Error-Handler : " + errorHandlerClass
                                        + " was not found. Fix your web.xml-parameter : "
                                        + ERROR_HANDLER_PARAMETER, ex);
                            }
                            catch (IllegalAccessException ex)
                            {
                                throw new FacesException("Constructor of error-Handler : " + errorHandlerClass
                                        + " is not accessible. Error-Handler is specified in web.xml-parameter : "
                                        + ERROR_HANDLER_PARAMETER, ex);
                            }
                            catch (InstantiationException ex)
                            {
                                throw new FacesException("Error-Handler : " + errorHandlerClass
                                    + " could not be instantiated. Error-Handler is specified in web.xml-parameter : "
                                    + ERROR_HANDLER_PARAMETER, ex);
                            }
                            catch (NoSuchMethodException ex)
                            {
                                throw new FacesException("Error-Handler : " + errorHandlerClass
                                        + " does not have a method with name : handleException and parameters : "
                                        + "javax.faces.context.FacesContext, java.lang.Exception. Error-Handler is"
                                        + "specified in web.xml-parameter : " + ERROR_HANDLER_PARAMETER, ex);
                            }
                            catch (InvocationTargetException ex)
                            {
                                throw new FacesException("Excecution of method handleException in Error-Handler : "
                                        + errorHandlerClass
                                        + " caused an exception. Error-Handler is specified in web.xml-parameter : "
                                        + ERROR_HANDLER_PARAMETER, ex);
                            }
                        }
                        else
                        {
                            // 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

                // 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

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.