org.springframework.richclient.exceptionhandling
Class MessagesDialogExceptionHandler

java.lang.Object
  extended by org.springframework.richclient.exceptionhandling.AbstractRegisterableExceptionHandler
      extended by org.springframework.richclient.exceptionhandling.AbstractLoggingExceptionHandler
          extended by org.springframework.richclient.exceptionhandling.AbstractDialogExceptionHandler
              extended by org.springframework.richclient.exceptionhandling.MessagesDialogExceptionHandler
All Implemented Interfaces:
Thread.UncaughtExceptionHandler, InitializingBean, RegisterableExceptionHandler
Direct Known Subclasses:
JXErrorDialogExceptionHandler

public class MessagesDialogExceptionHandler
extends AbstractDialogExceptionHandler

Displays a message to the user which is fetched from the I18N files based on the class and superclasses of the throwable.

For example if an IllegalArgumentException is thrown, it will search for java.lang.IllegalArgumentException.caption and java.lang.IllegalArgumentException.description first, and if it cant find that it will try in order: java.lang.RuntimeException.caption/description, java.lang.Exception.caption/description and java.lang.Throwable.caption/description.

The exception message is passed as a parameter, but is idented and wrapped first. Note for the repacing of {0} to work in a property file double quotes(") need to be escaped (\") and that single quotes (') should be avoided (escaping doesn't seem to work).

Since:
0.3
Author:
Geoffrey De Smet

Field Summary
 
Fields inherited from class org.springframework.richclient.exceptionhandling.AbstractDialogExceptionHandler
messageSourceAccessor, modalDialog, shutdownPolicy
 
Fields inherited from class org.springframework.richclient.exceptionhandling.AbstractLoggingExceptionHandler
exceptionPurger, LOG_MESSAGE, logger, logLevel
 
Constructor Summary
MessagesDialogExceptionHandler()
           
 
Method Summary
 Object createExceptionContent(Throwable throwable)
           
protected  String formatMessage(String message)
           
 String resolveExceptionCaption(Throwable throwable)
           
 void setIdentLength(int identLength)
          Sets the identation applied on the exception message passed as a parameter.
 void setMessagesKey(String messagesKey)
          If messagesKey is set, the caption and description shown in the dialog are not based dynamically on the throwable, but instead statically on the keys messageKey.caption and messageKey.description.
 void setWrapLength(int wrapLength)
          Sets the wrap length applied on the exception message passed as a parameter.
 
Methods inherited from class org.springframework.richclient.exceptionhandling.AbstractDialogExceptionHandler
afterPropertiesSet, notifyUserAboutException, resolveParentFrame, setMessageSourceAccessor, setModalDialog, setShutdownPolicy
 
Methods inherited from class org.springframework.richclient.exceptionhandling.AbstractLoggingExceptionHandler
logException, setExceptionPurger, setLogLevel, uncaughtException
 
Methods inherited from class org.springframework.richclient.exceptionhandling.AbstractRegisterableExceptionHandler
registerExceptionHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessagesDialogExceptionHandler

public MessagesDialogExceptionHandler()
Method Detail

setWrapLength

public void setWrapLength(int wrapLength)
Sets the wrap length applied on the exception message passed as a parameter. Defaults to 120.

Parameters:
wrapLength -

setIdentLength

public void setIdentLength(int identLength)
Sets the identation applied on the exception message passed as a parameter. Defaults to 2.

Parameters:
identLength -

setMessagesKey

public void setMessagesKey(String messagesKey)
If messagesKey is set, the caption and description shown in the dialog are not based dynamically on the throwable, but instead statically on the keys messageKey.caption and messageKey.description.

Parameters:
messagesKey - the key used for the caption and title

resolveExceptionCaption

public String resolveExceptionCaption(Throwable throwable)
Specified by:
resolveExceptionCaption in class AbstractDialogExceptionHandler

createExceptionContent

public Object createExceptionContent(Throwable throwable)
Specified by:
createExceptionContent in class AbstractDialogExceptionHandler

formatMessage

protected String formatMessage(String message)


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.