Class FeedbackMessage

java.lang.Object
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.

The values passed into the constructors should not be encoded for JavaScript or HTML usage. The JSCA client-side code will take care of encoding all values. If FeedbackMessages are rendered by other custom or non-JSCA utilities, it is their responsibility to deal with any encoding or security issues.

Supported API: true

Extendable: false

See Also:
  • Constructor Details

    • FeedbackMessage

      public FeedbackMessage(FeedbackType type, Locale locale, String msgTitle, ArrayList<String> incorrectFieldNames, String... msgs) throws WTException
      Constructor that accepts localized message strings.

      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
      Constructor that accepts LocalizableMessage strings.

      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 Details

    • 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(String msg, boolean checkXSS)
      Adds a localized message to the message list.

      Supported API: true
      Parameters:
      msg - - message to add. Required.
      checkXSS - - indicates whether the message must be encoded to prevent XSS attacks
    • addMessage

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

      Supported API: true
      Parameters:
      msg - - message to add. Required.
    • addMessage

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

      Supported API: true
      Parameters:
      msg - - message to add. Required.
      checkXSS - - indicates whether the message must be encoded to prevent XSS attacks
    • getLocalizedDisplayMessage

      public String getLocalizedDisplayMessage()
      Returns a formatted, localized, multiline display message.

      Supported API: true
      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.
      messageTitle - - 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 messageTitle argument will be ignored.
      locale - - Locale to use for localization of the Message Type string. Optional. If null, SessionHelper.getLocale() will be used.
      messageTitle - - Localized message title. Optional.
      messsageText - - One or more localized message text strings. Optional.