Class TemplateMessageUtil

java.lang.Object
com.flowable.engage.engine.impl.util.TemplateMessageUtil

public class TemplateMessageUtil
extends java.lang.Object
This utility helps creating template based standard messages. If you want to create your own standard message:
  • create a message code within StandardMessageCodes
  • add message template as a JSON resource in `com/flowable/template/default/` with name `standard-{yourMessageCode}_en.tplvariation`
  • optionally add message template as a JSON resource in `com/flowable/template/default/` with name `standard-{yourMessageCode}_{languageCode}.tplvariation` for any further languages you want to support
You can then use createMessage(String, Map) or createMessage(String, String, Map) to render a message based on your template.
Author:
Micha Kiener
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String FALLBACK_LANGUAGE
    The default language if no language is set
    static java.lang.String STANDARD_MESSAGES_TEMPLATE_KEY
    The template definition key used for standard messages.
    static java.lang.String VARIANT_KEY_LANGUAGE  
    static java.lang.String VARIANT_KEY_MESSAGE_CODE  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String createMessage​(java.lang.String messageTemplateKey, java.lang.String messageCode, java.lang.String language, java.util.Map<java.lang.String,​java.lang.Object> payload, java.lang.String tenantId)
    Creates a message based on the provided template key, message code and payload.
    static java.lang.String createMessage​(java.lang.String messageCode, java.lang.String language, java.util.Map<java.lang.String,​java.lang.Object> payload)
    Creates a standard message based on the provided message code and payload.
    static java.lang.String createMessage​(java.lang.String messageCode, java.util.Map<java.lang.String,​java.lang.Object> payload)
    Creates a standard message based on the provided message code and payload.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • createMessage

      public static java.lang.String createMessage​(java.lang.String messageCode, java.util.Map<java.lang.String,​java.lang.Object> payload)
      Creates a standard message based on the provided message code and payload. The payload must at least contain the necessary parameters as being defined within the TemplateVariationModel. This one uses english as the default language.
      Parameters:
      messageCode - the message code to choose the template variation for
      payload - the optional payload containing the necessary parameters (if any needed by the template)
      Returns:
      the rendered standard message
    • createMessage

      public static java.lang.String createMessage​(java.lang.String messageCode, java.lang.String language, java.util.Map<java.lang.String,​java.lang.Object> payload)
      Creates a standard message based on the provided message code and payload. The payload must at least contain the necessary parameters as being defined within the TemplateVariationModel.
      Parameters:
      messageCode - the message code to choose the template variation for
      language - the language (e.g. "en") for which the message should be rendered
      payload - the optional payload containing the necessary parameters (if any needed by the template)
      Returns:
      the rendered standard message
    • createMessage

      public static java.lang.String createMessage​(java.lang.String messageTemplateKey, java.lang.String messageCode, java.lang.String language, java.util.Map<java.lang.String,​java.lang.Object> payload, java.lang.String tenantId)
      Creates a message based on the provided template key, message code and payload. The payload must at least contain the necessary parameters as being defined within the TemplateVariationModel.
      Parameters:
      messageTemplateKey - the template key of the message template to be used
      messageCode - the message code to choose the template variation for
      language - the language (e.g. "en") for which the message should be rendered
      payload - the optional payload containing the necessary parameters (if any needed by the template)
      tenantId - for the message
      Returns:
      the rendered standard message