Class ActionMessages
- java.lang.Object
-
- jetbrains.buildServer.controllers.ActionMessages
-
public class ActionMessages extends Object
Storage for various messages (success messages, information messages and so on). The stored messages can be shown in JSP with help of <bs:messages/> tag where bs prefix is bounded to /WEB-INF/tags URI. The messages are stored in the session, once the message is shown it is deleted automatically after the request processing is finished.ActionMessagesclass is responsible for proper messages XML escaping. If the client wants to pass a raw HTML there, he/she should be usingaddRawMessage(String, String, String...)explicitly. In this case the responsibility is passed to the client.- See Also:
ActionMessage
-
-
Constructor Summary
Constructors Constructor Description ActionMessages()Creates a new storage
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessage(String key, String message)Adds a message with specified key to the storage.voidaddMessage(String key, String message, String... parameters)Adds a message with specified key to the storage.voidaddMessage(ActionMessage message)Adds a message with specified key to the storage.voidaddRawMessage(String key, String message, String... parameters)Adds a message with specified key to the storage.voidclearMessages()Removes all currently stored messagesvoidclearReadMessages()Removes all read messages from the storage.ActionMessagegetActionMessage(String key)Returns a message with specified key and marks this message as read.StringgetMessage(String key)Returns a string message with specified key and marks this message as read.Collection<ActionMessage>getMessages()Returns all messages and all of them as read.static ActionMessagesgetMessages(javax.servlet.http.HttpServletRequest request)ObtainsActionMessagesobject from the specified request.static ActionMessagesgetOrCreateMessages(javax.servlet.http.HttpServletRequest request)ObtainsActionMessagesobject from the specified request or creates a new one if there is no such object.booleanhasMessage(String key)Returns true if this storage contains a message with specified keybooleanhasMessages()voidremoveMessage(String key)Removes the message with the specified key from the storage.StringtoString()
-
-
-
Method Detail
-
getOrCreateMessages
@NotNull public static ActionMessages getOrCreateMessages(@NotNull javax.servlet.http.HttpServletRequest request)
ObtainsActionMessagesobject from the specified request or creates a new one if there is no such object.- Parameters:
request- request- Returns:
ActionMessagesobject
-
getMessages
@Nullable public static ActionMessages getMessages(@NotNull javax.servlet.http.HttpServletRequest request)
ObtainsActionMessagesobject from the specified request.- Parameters:
request- request- Returns:
ActionMessagesobject or null
-
addMessage
public void addMessage(@NotNull ActionMessage message)Adds a message with specified key to the storage.- Parameters:
message- message
-
addMessage
public void addMessage(@NotNull String key, @NotNull String message)Adds a message with specified key to the storage.The caller cannot pass raw HTML message using this method, as the
messagewill be escaped.- Parameters:
key- message keymessage- message
-
addMessage
public void addMessage(@NotNull String key, @NotNull String message, @NotNull String... parameters)Adds a message with specified key to the storage. Message can contain placeholders for parameters.The caller cannot pass raw HTML message using this method, as the
messagewill be escaped.- Parameters:
key- message keymessage- messageparameters- if specified then substrings like {0}, {1}, {2} and so on will be replaced with parameter with corresponding index. Each parameter will be passed throughWebUtil.escapeXml(String)function before inserted into the resulting message.- See Also:
addRawMessage(String, String, String...)
-
addRawMessage
public void addRawMessage(@NotNull String key, @NotNull String message, @NotNull String... parameters)Adds a message with specified key to the storage. Message can contain placeholders for parameters.The caller is allowed to use raw HTML in a
message(and thus is responsible of escaping of any untrusted user data there). The parameters are escaped, no HTML can be passed there.- Parameters:
key- message keymessage- messageparameters- if specified then substrings like {0}, {1}, {2} and so on will be replaced with parameter with corresponding index. Each parameter will be passed throughWebUtil.escapeXml(String)function before inserted into the resulting message.- Since:
- 7.1
- See Also:
addMessage(String, String, String...)
-
removeMessage
public void removeMessage(@NotNull String key)Removes the message with the specified key from the storage.- Parameters:
key- message key- Since:
- 8.0
-
getMessage
@Nullable public String getMessage(@NotNull String key)
Returns a string message with specified key and marks this message as read.- Parameters:
key- message key- Returns:
- a message with specified key
-
getActionMessage
@Nullable public ActionMessage getActionMessage(@NotNull String key)
Returns a message with specified key and marks this message as read.- Parameters:
key- message key- Returns:
- a message with specified key
-
getMessages
@NotNull public Collection<ActionMessage> getMessages()
Returns all messages and all of them as read.- Returns:
- collection of messages
-
hasMessage
public boolean hasMessage(@NotNull String key)Returns true if this storage contains a message with specified key- Parameters:
key- message key- Returns:
- true if this storage contains a message with specified key
-
clearReadMessages
public void clearReadMessages()
Removes all read messages from the storage.
-
hasMessages
public boolean hasMessages()
- Returns:
- true if this storage contains at least one message.
-
clearMessages
public void clearMessages()
Removes all currently stored messages
-
-