ICEfaces
  1. ICEfaces
  2. ICE-6004

Add a custom ExceptionHandler to help with server side exception handling.

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Beta1
    • Fix Version/s: 2.0-Beta2, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces 2

      Description

      The standard Servlet mechanism for handling server-side exceptions is to specify an error-page entry in the web.xml file and allow the container to redirect to the configured resource. For example:

          <error-page>
              <exception-type>javax.faces.application.ViewExpiredException</exception-type>
              <location>/faces/viewExpired.xhtml</location>
          </error-page>

      This works fine as long as the exception makes it up to the servlet container. If the exception is handled in some other way where it doesn't bubble up to the container, then this mechanism is not effective.

      For JSF 2, there is way to provide your own hook for exception handling. This is done using an ExceptionHandlerFactory and one or more custom ExceptionHandlers. By default, Mojarra provides implementations of both a standard ExceptionHandler for normal requests as well as an Ajax implementation for Ajax requests. Ajax requests in particular are bundled up as Ajax responses and sent back to the client without bubbling up the container so the error-page mechanism is bypassed.

      We can potentially add value to ICEfaces by providing customized exception handling, particularly for Ajax requests. ExceptionHandlers are request-scoped resources (a new one for each request). The basic mechanism is to create an ExceptionHandlerFactory that links into the chain of existing ExceptionHandlerFactories and then creates an ExceptionHandler passing in the ExceptionHandler for wrapping. For example:


      package org.icefaces.context;

      import javax.faces.context.ExceptionHandler;
      import javax.faces.context.ExceptionHandlerFactory;

      public class ExceptionHandlerFactoryImpl extends ExceptionHandlerFactory {

          ExceptionHandlerFactory delegateFactory;

          public ExceptionHandlerFactoryImpl(ExceptionHandlerFactory delegateFactory) {
              this.delegateFactory = delegateFactory;
          }

          public ExceptionHandler getExceptionHandler() {
              return new MyExceptionHandler(delegateFactory.getExceptionHandler());
          }
      }

        Issue Links

          Activity

          Hide
          Deryk Sinotte added a comment -

          The custom ExceptionHandler (and factory) have been added. ViewExpiredExceptions that occur during the Restore View phase are now detected and turned into SessionExpiredExceptions. If ICEpush is available, the notifications are pushed out to all Windows related to the expired session.

          Show
          Deryk Sinotte added a comment - The custom ExceptionHandler (and factory) have been added. ViewExpiredExceptions that occur during the Restore View phase are now detected and turned into SessionExpiredExceptions. If ICEpush is available, the notifications are pushed out to all Windows related to the expired session.

            People

            • Assignee:
              Deryk Sinotte
              Reporter:
              Deryk Sinotte
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: