com.ptc.core.components.util
Class FeedbackMessage

java.lang.Object
  extended by com.ptc.core.components.util.FeedbackMessage
All Implemented Interfaces:
Serializable

public class FeedbackMessage
extends Object
implements Serializable

A class used for creating standardized user feedback messages for display in javascript alert or confirm dialog windows. Messages are formatted as follows:

<MESSAGE_TYPE_STRING>: <Message title>

<Message text 1>
<Message text 2>
.
.
<Message text n >

The MESSAGE_TYPE_STRING will be automatically generated based on the input message type.

Can accept localized or nonlocalized message title and message text.

Supported API: true

Extendable: false

See Also:
Serialized Form

Constructor Summary
FeedbackMessage(FeedbackType type, Locale locale, LocalizableMessage msgTitle, ArrayList<String> incorrectFieldNames, LocalizableMessage... msgs)
          

Supported API: true
FeedbackMessage(FeedbackType type, Locale locale, String msgTitle, ArrayList<String> incorrectFieldNames, String... msgs)
          

Supported API: true
 
Method Summary
 void addMessage(LocalizableMessage msg)
          Adds a localizable message to the message list.
 void addMessage(String msg)
          Adds a localized message to the message list.
static String formatException(Throwable t, LocalizableMessage messageTitle, boolean includeNested, Locale locale)
          Format a Throwable message into a standard multiline message string


The text displayed for MESSAGE_TYPE will be that appropriate for messages of type FeedbackType.FAILURE.
static String formatMessage(FeedbackType type, Locale locale, String messageTitle, String... messageText)
          Formats the localized input text into the standard message format described in the class-level javadoc.
 String getLocalizedDisplayMessage()
          Returns a formatted, localized, multi-line display message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeedbackMessage

public FeedbackMessage(FeedbackType type,
                       Locale locale,
                       String msgTitle,
                       ArrayList<String> incorrectFieldNames,
                       String... msgs)
                throws WTException


Supported API: true

Parameters:
type - - Message type. Only the following three types are handled: FeedbackType.SUCCESS, FeedbackType.FAILURE, and FeedbackType.CONFIRMATION. Optional.
locale - - Locale to use for localization. Optional. If null, SessionHelper.getLocale() will be used.
msgTitle - - Localized message title. Optional.
incorrectFieldNames - - Name attribute of the incorrect input field(s) with which this message is associated so user can be returned to that field. Currently not used.
msgs - - One or more localized message text strings. Optional.
Throws:
WTException

FeedbackMessage

public FeedbackMessage(FeedbackType type,
                       Locale locale,
                       LocalizableMessage msgTitle,
                       ArrayList<String> incorrectFieldNames,
                       LocalizableMessage... msgs)
                throws WTException


Supported API: true

Parameters:
type - - Message type. Only the following three types are handled: FeedbackType.SUCCESS, FeedbackType.FAILURE, and FeedbackType.CONFIRMATION. Optional.
locale - - Locale to use for localization. Optional. If null, SessionHelper.getLocale() will be used.
incorrectFieldNames - - Name attribute of the incorrect input field(s) with which this message is associated so user can be returned to that field. Currently not used.
msgTitle - - Localizable message title. Optional.
msgs - - One or more localizable message text strings. Optional.
Throws:
WTException
Method Detail

addMessage

public void addMessage(String msg)
Adds a localized message to the message list.

Supported API: true

Parameters:
msg - - message to add. Required.

addMessage

public void addMessage(LocalizableMessage msg)
Adds a localizable message to the message list.

Supported API: true

Parameters:
msg - - message to add. Required.

getLocalizedDisplayMessage

public String getLocalizedDisplayMessage()
Returns a formatted, localized, multi-line display message.

Supported API: true

Parameters:
locale - - locale to use for localization. Optional. If null, locale will be obtained from SessionHelper.getLocale().
Returns:
Formatted and localized message text (multiple lines).

formatException

public static String formatException(Throwable t,
                                     LocalizableMessage messageTitle,
                                     boolean includeNested,
                                     Locale locale)
Format a Throwable message into a standard multiline message string


The text displayed for MESSAGE_TYPE will be that appropriate for messages of type FeedbackType.FAILURE.

Supported API: true

Parameters:
t - - Throwable containing message to display. Required.
msgTitle - - Localized message title. Optional.
includeNested - - if true and t is a WTException, nested exception messages will also be returned. Required.
locale - - Locale to use for localization. Optional. If null, SessionHelper.getLocale() will be used.
Returns:
Formatted and localized message text (multiple lines).

formatMessage

public static String formatMessage(FeedbackType type,
                                   Locale locale,
                                   String messageTitle,
                                   String... messageText)
Formats the localized input text into the standard message format described in the class-level javadoc.

Supported API: true

Parameters:
type - - Message type. Only the following three types are handled: FeedbackType.SUCCESS, FeedbackType.FAILURE, and FeedbackType.CONFIRMATION. Optional. If null, no title line will be returned and msgTitle will be ignored.
locale - - Locale to use for localization of the Message Type string. Optional. If null, SessionHelper.getLocale() will be used.
msgTitle - - Localized message title. Optional.
msgs - - One or more localized message text strings. Optional.