public class Message extends Object
UserContext
to collect error or success messages.Modifier and Type | Field and Description |
---|---|
static String |
ERROR
Declares a message as error.
|
static String |
INFO
Declares a message as information.
|
static String |
SUCCESS
Declares a message as success.
|
static String |
WARN
Declares a message as warning.
|
Constructor and Description |
---|
Message()
Creates a new empty message.
|
Message(String message,
String details,
String type)
Creates a new message with the given content, details info and message type.
|
Modifier and Type | Method and Description |
---|---|
static Message |
error(String message)
Factory method to create an error message
|
static Message |
error(Throwable t)
Factory method to create an error message
|
String |
getAction()
Returns the action associated with the message
|
String |
getActionLabel()
Returns the label to be used for the action
|
String |
getDetails()
Returns detailed infos for this message
|
String |
getMessage()
Returns the message for the user.
|
String |
getType()
Returns the type of the message
|
static Message |
info(String message)
Factory method to create a info message
|
boolean |
isActionJavascript()
Determines if the action is an URL or a piece of JavaScript
|
void |
setAction(String action) |
void |
setActionJavascript(boolean actionJavascript) |
void |
setActionLabel(String actionLabel) |
void |
setDetails(String details) |
void |
setMessage(String message) |
void |
setType(String type) |
static Message |
success(String message)
Factory method to create a success message
|
String |
toString() |
static Message |
warn(String message)
Factory method to create a warning as message
|
Message |
withAction(String link,
String label)
Adds an action as URL to the message
|
Message |
withJavascriptAction(String codeFragment,
String label)
Adds an action as URL to the message
|
public static final String SUCCESS
public static final String INFO
public static final String WARN
public static final String ERROR
public Message(String message, String details, String type)
message
- the message to show to the userdetails
- the details for this messagetype
- the type for the messagepublic Message()
public String getMessage()
public String getDetails()
public String getType()
public String getAction()
public String getActionLabel()
public boolean isActionJavascript()
public Message withAction(String link, String label)
link
- the URL to invoke if the user clicks on the messagelabel
- the label to use for the given actionpublic Message withJavascriptAction(String codeFragment, String label)
codeFragment
- the URL to invoke if the user clicks on the messagelabel
- the label to use for the given actionpublic static Message success(String message)
message
- the message contentpublic static Message info(String message)
message
- the message contentpublic static Message warn(String message)
message
- the message contentpublic static Message error(String message)
message
- the message contentpublic static Message error(Throwable t)
t
- the exception containing the error messagepublic void setMessage(String message)
public void setDetails(String details)
public void setType(String type)
public void setAction(String action)
public void setActionLabel(String actionLabel)
public void setActionJavascript(boolean actionJavascript)
Copyright © 2018. All rights reserved.