Пример #1
0
  @Override
  public void processEvent(SystemEvent event) throws AbortProcessingException {

    ExceptionQueuedEvent e = (ExceptionQueuedEvent) event;
    UIComponent component = e.getContext().getComponent();
    Throwable exception = e.getContext().getException();

    LOGGER.info("#################################");
    LOGGER.info("SystemEventListener.processEvent : {}", component);
    LOGGER.info("SystemEventListener.processEvent : {}", exception);
    LOGGER.info("#################################");
  }
 @Override
 public void handle() throws FacesException {
   Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator();
   while (it.hasNext()) {
     try {
       ExceptionQueuedEvent evt = it.next();
       // Fires the Event with the Exception (with expected Qualifier) to
       // be handled
       ExceptionToCatchEvent etce =
           new ExceptionToCatchEvent(
               evt.getContext().getException(), FacesRequestLiteral.INSTANCE);
       beanManager.fireEvent(etce);
     } finally {
       it.remove();
     }
   }
   getWrapped().handle();
 }
  /** Metodo que efetivamente manipula a exception. */
  @Override
  public void handle() throws FacesException {
    // iterage para pegar todas as exceptions geradas
    for (ExceptionQueuedEvent event : getUnhandledExceptionQueuedEvents()) {

      ExceptionQueuedEventContext context = event.getContext();

      Throwable throwable = context.getException(); // tipo FacesException

      Throwable essenciaException = getAlternativeRootCause(throwable);

      if (essenciaException instanceof NegocioException) {
        JSFUtil.addErrorMessage(essenciaException);

      } else {
        JSFUtil.addFatalMessage("Erro inesperado", essenciaException);
      }
    }
  }
Пример #4
0
  @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();
      eqec.getException().printStackTrace();
      //            if(eqec.getException() instanceof ViewExpiredException) {
      //                FacesContext context = eqec.getContext();
      //                if(!context.isReleased()) {
      //                    NavigationHandler navHandler =
      // context.getApplication().getNavigationHandler();
      //
      //                    try {
      //
      //                    	//FIXME:session超时挂掉等等,跳转到相应页面,给提示。
      ////                    	FacesUtil.addErrorMessage("长时间未操作。");
      //                    	String originalViewId = context.getViewRoot().getViewId();
      //                    	if (originalViewId.endsWith(".xhtml")) {
      //                    		String redirectUrl = originalViewId.substring(0,
      // originalViewId.length()-6);
      //                    		navHandler.handleNavigation(context, null,
      // redirectUrl+"?faces-redirect=true&expired=true");
      //						}
      ////                        navHandler.handleNavigation(context, null,
      // "pretty:home?faces-redirect=true&expired=true");
      //                    }
      //                    finally {
      //                        it.remove();
      //                    }
      //                }
      //
      //            }
    }

    this.wrapped.handle();
  }