Class MessageStructureUtils

java.lang.Object
org.kuali.rice.krad.uif.util.MessageStructureUtils

public class MessageStructureUtils extends Object
Rich message structure utilities for parsing message content and converting it to components/content
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • MessageStructureUtils

      public MessageStructureUtils()
  • Method Details

    • translateStringMessage

      public static String translateStringMessage(String messageText)
      Translate a message with special hooks described in MessageStructureUtils.parseMessage. However, tags which reference components will not be allowed/translated - only tags which can translate to string content will be included for this translation.
      Parameters:
      messageText - messageText with only String translateable tags included (no id or component index tags)
      Returns:
      html translation of rich messageText passed in
      See Also:
    • parseMessage

      public static List<Component> parseMessage(String messageId, String messageText, List<Component> componentList, View view, boolean parseComponents)
      Parses the message text passed in and returns the resulting rich message component structure.

      If special characters [] are detected the message is split at that location. The types of features supported by the parse are (note that <> are not part of the content, they specify placeholders):

      • [id=<component id>] - insert component with id specified at that location in the message
      • [n] - insert component at index n from the inlineComponent list
      • [<html tag>][/<html tag>] - insert html content directly into the message content at that location, without the need to escape the <> characters in xml
      • [color=<html color code/name>][/color] - wrap content in color tags to make text that color in the message
      • [css=<css classes>][/css] - apply css classes specified to the wrapped content - same as wrapping the content in span with class property set
      • [link=<href src>][/link] - an easier way to create an anchor that will open in a new page to the href specified after =
      • [action=<href src>][/action] - create an action link inline without having to specify a component by id or index. The options for this are as follows and MUST be in a comma seperated list in the order specified (specify 1-4 always in this order):
        • methodToCall(String)
        • validateClientSide(boolean) - true if not set
        • ajaxSubmit(boolean) - true if not set
        • successCallback(js function or function declaration) - this only works when ajaxSubmit is true
        The tag would look something like this [action=methodToCall]Action[/action] in most common cases. And in more complex cases [action=methodToCall,true,true,functionName]Action[/action].

        In addition to these settings, you can also specify data to send to the server in this fashion (space is required between settings and data):

        [action=<action settings> data={key1: 'value 1', key2: value2}]

      If the [] characters are needed in message text, they need to be declared with an escape character: \\[ \\]

      Parameters:
      messageId - id of the message
      messageText - message text to be parsed
      componentList - the inlineComponent list
      view - the current view
      parseComponents - true to parse components
      Returns:
      list of components representing the parsed message structure
    • addBlanks

      public static String addBlanks(String text)
      Inserts &nbsp; into the string passed in, if spaces exist at the beginning and/or end, so spacing is not lost in html translation.
      Parameters:
      text - string to insert &nbsp;
      Returns:
      String with &nbsp; inserted, if applicable