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.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault MessageadditionalTargets(MessageTarget... additionalTargets) Sets the provided array ofMessageTargetinstances as additional targets.additionalTargets(List<MessageTarget> additionalTargets) Sets the provided list ofMessageTargetinstances as additional targets.Adds the passedcodeto the current message.static Messagecreate(Message.Severity severity, String text) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.static Messagecreate(Message.Severity severity, String text, Message message) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.static Messagecreate(String text, ServiceException exception) This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.The optional list of additionalMessageTargetinstancesgetCode()The optional code of the messageThe optional long text urlThe localized messageTheMessageLookupThe severity of the message.The optionalMessageTargetbooleanReturnstrue, if the transition indicator is set for this message.longTextUrl(String longTextUrl) Adds the passedlongTextUrlto the current message.default Messagetarget(com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element) Adds the passed path and element as target to the currentMessage.target(MessageTarget target) Sets the providedMessageTargetdefault <E extends com.sap.cds.ql.StructuredType<E>>
MessageAdds the passed path as target to the currentMessage.default MessageSets the provided string-based target.default <E extends com.sap.cds.ql.StructuredType<E>>
MessageAdds the passed target parameter and path as target to the currentMessage.default MessageAdds the passed target parameter and path as target to the currentMessage.default MessageAdds the passed path as target to the currentMessage.transition(boolean isTransition) Sets thetransitionindicator of the current message.
-
Method Details
-
create
This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
severity- theMessage.Severityof theMessagetext- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.- Returns:
- Created
Messageinstance.
-
create
This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
severity- theMessage.Severityof theMessagetext- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.message- theMessageto copy optional arguments from- Returns:
- the
Messageinstance
-
create
This method creates a standalone instance ofMessagethat is not added to theMessagesof the activeRequestContext.- Parameters:
text- the final text of the message. For localization useCdsRuntime.getLocalizedMessage(String, Object[], Locale)explicitly.exception- theServiceExceptionto copy optional arguments from- Returns:
- the
Messageinstance
-
getMessage
String getMessage()The localized message- Returns:
- The localized message
-
getMessageLookup
MessageLookup getMessageLookup()TheMessageLookup- Returns:
- The
MessageLookup
-
getCode
String getCode()The optional code of the message- Returns:
- The code
-
getTarget
MessageTarget getTarget()The optionalMessageTarget- Returns:
- The
MessageTarget
-
getAdditionalTargets
List<MessageTarget> getAdditionalTargets()The optional list of additionalMessageTargetinstances- Returns:
- The list of additional MessageTarget instances
-
getLongTextUrl
String getLongTextUrl()The optional long text url- Returns:
- The long text url
-
isTransition
boolean isTransition()Returnstrue, if the transition indicator is set for this message.A transition message is a request-specific message, that is valid during the runtime of a request. It might not reoccur if the same request is processed again. A state message has a relation to an entity document. It is typically a validation (error) message.
- Returns:
true, if the transition indicator is set for this message
-
getSeverity
Message.Severity getSeverity()The severity of the message.- Returns:
- The severity
-
longTextUrl
Adds the passedlongTextUrlto the current message.- Parameters:
longTextUrl- The long text url to be set- Returns:
- The current message
-
code
Adds the passedcodeto the current message.- Parameters:
code- The code to be set- Returns:
- The current message
-
transition
Sets thetransitionindicator of the current message.A transition message is a request-specific message, that is valid during the runtime of a request. It might not reoccur if the same request is processed again. A state message has a relation to an entity document. It is typically a validation (error) message.
- Parameters:
isTransition-true, if the transition indicator should be set,false, if it should be unset- Returns:
- The current message
-
target
Sets the providedMessageTarget- Parameters:
target- theMessageTarget- Returns:
- The current message
-
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
Adds the passed path as target to the currentMessage.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
Adds the passed target parameter and path as target to the currentMessage.- Parameters:
parameter- target parameter serving as the entry point for the path resolution. PassingMessageTarget.PARAMETER_CQNindicates 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
default <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 currentMessage. 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
default <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 currentMessage. 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. PassingMessageTarget.PARAMETER_CQNindicates 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
Adds the passed path and element as target to the currentMessage.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
CdsDataProcessorand its functional interfaces.- Parameters:
path- the pathelement- the target element or association- Returns:
- the current message
-
additionalTargets
Sets the provided list ofMessageTargetinstances as additional targets.- Parameters:
additionalTargets- the list of additionalMessageTargetinstances.- Returns:
- the current message
-
additionalTargets
Sets the provided array ofMessageTargetinstances as additional targets.- Parameters:
additionalTargets- the array of additionalMessageTargetinstances.- Returns:
- the current message
-