Interface Message


public interface Message
Messages can be used to pass additional information along with the response. Some clients such as Fiori UIs provide controls to show these messages in a user friendly way.
  • Method Details

    • create

      static Message create(Message.Severity severity, String text)
      This method creates a standalone instance of Message that is not added to the Messages of the active RequestContext.
      Parameters:
      severity - the Message.Severity of the Message
      text - the final text of the message. For localization use CdsRuntime.getLocalizedMessage(String, Object[], Locale) explicitly.
      Returns:
      Created Message instance.
    • create

      static Message create(Message.Severity severity, String text, Message message)
      This method creates a standalone instance of Message that is not added to the Messages of the active RequestContext.
      Parameters:
      severity - the Message.Severity of the Message
      text - the final text of the message. For localization use CdsRuntime.getLocalizedMessage(String, Object[], Locale) explicitly.
      message - the Message to copy optional arguments from
      Returns:
      the Message instance
    • create

      static Message create(String text, ServiceException exception)
      This method creates a standalone instance of Message that is not added to the Messages of the active RequestContext.
      Parameters:
      text - the final text of the message. For localization use CdsRuntime.getLocalizedMessage(String, Object[], Locale) explicitly.
      exception - the ServiceException to copy optional arguments from
      Returns:
      the Message instance
    • getCode

      String getCode()
      The optional code of the message
      Returns:
      The code
    • getMessage

      String getMessage()
      The localized message
      Returns:
      The localized message
    • getTarget

      MessageTarget getTarget()
      The optional MessageTarget
      Returns:
      The MessageTarget
    • getLongTextUrl

      String getLongTextUrl()
      The optional long text url
      Returns:
      The long text url
    • getSeverity

      Message.Severity getSeverity()
      The severity of the message.
      Returns:
      The severity
    • longTextUrl

      Message longTextUrl(String longTextUrl)
      Adds the passed longTextUrl to the current message.
      Parameters:
      longTextUrl - The long text url to be set
      Returns:
      The current message
    • code

      Message code(String code)
      Adds the passed code to the current message.
      Parameters:
      code - The code to be set
      Returns:
      The current message
    • target

      Message target(String target)
      Sets the provided string-based target. No further processing of the string is performed.
      Parameters:
      target - the string-based target
      Returns:
      The current message
    • target

      Message target(Function<com.sap.cds.ql.StructuredType<?>,Object> path)
      Adds the passed path as target to the current Message. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. Is equivalent to calling target(MessageTarget.PARAMETER_CQN, path)
      Parameters:
      path - the path to the target element or association
      Returns:
      The current message
    • target

      Message target(String parameter, Function<com.sap.cds.ql.StructuredType<?>,Object> path)
      Adds the passed target parameter and path as target to the current Message.
      Parameters:
      parameter - target parameter serving as the entry point for the path resolution. Passing MessageTarget.PARAMETER_CQN indicates that the path should be interpreted relatively to the target entity of the request. Alternatively you can pass names of action or function parameters.
      path - the path to the target element or association
      Returns:
      The current message
    • target

      <E extends com.sap.cds.ql.StructuredType<E>> Message target(Class<E> type, Function<E,Object> path)
      Adds the passed path as target to the current Message. This method allows to build the path in a type-safe way, by passing the corresponding entity or structured type interface. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. Is equivalent to calling target(MessageTarget.PARAMETER_CQN, type, path)
      Type Parameters:
      E - the type of the root
      Parameters:
      type - the root type of the path. Either an entity or a structured type.
      path - the path to the target element or association
      Returns:
      The current message
    • target

      <E extends com.sap.cds.ql.StructuredType<E>> Message target(String parameter, Class<E> type, Function<E,Object> path)
      Adds the passed target parameter and path as target to the current Message. This method allows to build the path in a type-safe way, by passing the corresponding entity or structured type interface.
      Type Parameters:
      E - the type of the root
      Parameters:
      parameter - target parameter serving as the entry point for the path resolution. Passing MessageTarget.PARAMETER_CQN indicates that the path should be interpreted relatively to the target entity of the request. Alternatively you can pass names of action or function parameters.
      type - the root type of the path. Either an entity or a structured type.
      path - the path to the target element or association
      Returns:
      The current message
    • target

      Message target(com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element)
      Adds the passed path and element as target to the current Message. The path is interpreted relative to the CQN statement, which was determined from the request. For CRUD events this CQN statement points to the targeted entity. For bound actions or functions this CQN statement points to the bound entity. This method can be used with the CdsDataProcessor and its functional interfaces.
      Parameters:
      path - the path
      element - the target element or association
      Returns:
      the current message