com.vaadin.ui.
Class Window.Notification
java.lang.Object
com.vaadin.ui.Window.Notification
All Implemented Interfaces:
Enclosing class:
- extends Object
- implements Serializable
public static class Window.Notification
A notification message, used to display temporary messages to the user - for example "Document saved", or "Save failed".
The notification message can consist of several parts: caption, description and icon. It is usually used with only caption - one should be wary of filling the notification with too much information.
The notification message tries to be as unobtrusive as possible, while still drawing needed attention. There are several basic types of messages that can be used in different situations:
- TYPE_HUMANIZED_MESSAGE fades away quickly as soon as the user uses the mouse or types something. It can be used to show fairly unimportant messages, such as feedback that an operation succeeded ("Document Saved") - the kind of messages the user ignores once the application is familiar.
- TYPE_WARNING_MESSAGE is shown for a short while after the user uses the mouse or types something. It's default style is also more noticeable than the humanized message. It can be used for messages that do not contain a lot of important information, but should be noticed by the user. Despite the name, it does not have to be a warning, but can be used instead of the humanized message whenever you want to make the message a little more noticeable.
- TYPE_ERROR_MESSAGE requires to user to click it before disappearing, and can be used for critical messages.
- TYPE_TRAY_NOTIFICATION is shown for a while in the lower left corner of the window, and can be used for "convenience notifications" that do not have to be noticed immediately, and should not interfere with the current task - for instance to show "You have a new message in your inbox" while the user is working in some other area of the application.
In addition to the basic pre-configured types, a Notification can also be configured to show up in a custom position, for a specified time (or until clicked), and with a custom stylename. An icon can also be added.
See Also:
Field Summary | |
---|---|
static int |
DELAY_FOREVER
|
static int |
DELAY_NONE
|
static int |
POSITION_BOTTOM_LEFT
|
static int |
POSITION_BOTTOM_RIGHT
|
static int |
POSITION_CENTERED
|
static int |
POSITION_CENTERED_BOTTOM
|
static int |
POSITION_CENTERED_TOP
|
static int |
POSITION_TOP_LEFT
|
static int |
POSITION_TOP_RIGHT
|
static int |
TYPE_ERROR_MESSAGE
|
static int |
TYPE_HUMANIZED_MESSAGE
|
static int |
TYPE_TRAY_NOTIFICATION
|
static int |
TYPE_WARNING_MESSAGE
|
Constructor Summary | |
---|---|
Window.Notification(String caption)
Creates a "humanized" notification message. |
|
Window.Notification(String caption,
int type)
Creates a notification message of the specified type. |
|
Window.Notification(String caption,
String description)
Creates a "humanized" notification message with a bigger caption and smaller description. |
|
Window.Notification(String caption,
String description,
int type)
Creates a notification message of the specified type, with a bigger caption and smaller description. |
|
Window.Notification(String caption,
String description,
int type,
boolean htmlContentAllowed)
Creates a notification message of the specified type, with a bigger caption and smaller description. |
Method Summary | |
---|---|
String |
getCaption()
Gets the caption part of the notification message. |
int |
getDelayMsec()
Gets the delay before the notification disappears. |
String |
getDescription()
Gets the description part of the notification message. |
Resource |
getIcon()
Gets the icon part of the notification message. |
String |
getMessage()
Deprecated. Use getDescription() instead. |
int |
getPosition()
Gets the position of the notification message. |
String |
getStyleName()
Gets the style name for the notification message. |
boolean |
isHtmlContentAllowed()
Checks whether caption and description are interpreted as html or plain text. |
void |
setCaption(String caption)
Sets the caption part of the notification message |
void |
setDelayMsec(int delayMsec)
Sets the delay before the notification disappears. |
void |
setDescription(String description)
Sets the description part of the notification message. |
void |
setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the caption and description. |
void |
setIcon(Resource icon)
Sets the icon part of the notification message. |
void |
setMessage(String description)
Deprecated. Use setDescription(String) instead. |
void |
setPosition(int position)
Sets the position of the notification message. |
void |
setStyleName(String styleName)
Sets the style name for the notification message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
TYPE_HUMANIZED_MESSAGE
public static final int TYPE_HUMANIZED_MESSAGE
See Also:
TYPE_WARNING_MESSAGE
public static final int TYPE_WARNING_MESSAGE
See Also:
TYPE_ERROR_MESSAGE
public static final int TYPE_ERROR_MESSAGE
See Also:
TYPE_TRAY_NOTIFICATION
public static final int TYPE_TRAY_NOTIFICATION
See Also:
POSITION_CENTERED
public static final int POSITION_CENTERED
See Also:
POSITION_CENTERED_TOP
public static final int POSITION_CENTERED_TOP
See Also:
POSITION_CENTERED_BOTTOM
public static final int POSITION_CENTERED_BOTTOM
See Also:
POSITION_TOP_LEFT
public static final int POSITION_TOP_LEFT
See Also:
POSITION_TOP_RIGHT
public static final int POSITION_TOP_RIGHT
See Also:
POSITION_BOTTOM_LEFT
public static final int POSITION_BOTTOM_LEFT
See Also:
POSITION_BOTTOM_RIGHT
public static final int POSITION_BOTTOM_RIGHT
See Also:
DELAY_FOREVER
public static final int DELAY_FOREVER
See Also:
DELAY_NONE
public static final int DELAY_NONE
See Also:
Constructor Detail |
---|
Window.Notification
public Window.Notification(String caption)
- Parameters:
caption
- The message to show
Creates a "humanized" notification message. Care should be taken to to avoid XSS vulnerabilities as the caption is by default rendered as html.
Window.Notification
public Window.Notification(String caption,
int type)
- Parameters:
caption
- The message to showtype
- The type of message
Creates a notification message of the specified type. Care should be taken to to avoid XSS vulnerabilities as the caption is by default rendered as html.
Window.Notification
public Window.Notification(String caption,
String description)
- Parameters:
caption
- The message captiondescription
- The message description
Creates a "humanized" notification message with a bigger caption and smaller description. Care should be taken to to avoid XSS vulnerabilities as the caption and description are by default rendered as html.
Window.Notification
public Window.Notification(String caption,
String description,
int type)
- Parameters:
caption
- The message captiondescription
- The message descriptiontype
- The type of message
Creates a notification message of the specified type, with a bigger caption and smaller description. Care should be taken to to avoid XSS vulnerabilities as the caption and description are by default rendered as html.
Window.Notification
public Window.Notification(String caption,
String description,
int type,
boolean htmlContentAllowed)
- Parameters:
caption
- The message captiondescription
- The message descriptiontype
- The type of messagehtmlContentAllowed
- Whether html in the caption and description should be displayed as html or as plain text
Creates a notification message of the specified type, with a bigger caption and smaller description. Care should be taken to to avoid XSS vulnerabilities if html is allowed.
Method Detail |
---|
getCaption
public String getCaption()
- Returns:
- The message caption
Gets the caption part of the notification message.
setCaption
public void setCaption(String caption)
- Parameters:
caption
- The message caption
Sets the caption part of the notification message
getMessage
@Deprecated
public String getMessage()
- Returns:
Deprecated. Use getDescription()
instead.
setMessage
@Deprecated
public void setMessage(String description)
- Parameters:
description
-
Deprecated. Use setDescription(String)
instead.
getDescription
public String getDescription()
- Returns:
- The message description.
Gets the description part of the notification message.
setDescription
public void setDescription(String description)
- Parameters:
description
-
Sets the description part of the notification message.
getPosition
public int getPosition()
- Returns:
- The position
Gets the position of the notification message.
setPosition
public void setPosition(int position)
- Parameters:
position
- The desired notification position
Sets the position of the notification message.
getIcon
public Resource getIcon()
- Returns:
- The message icon
Gets the icon part of the notification message.
setIcon
public void setIcon(Resource icon)
- Parameters:
icon
- The desired message icon
Sets the icon part of the notification message.
getDelayMsec
public int getDelayMsec()
- Returns:
- the delay in msec, -1 indicates the message has to be clicked.
Gets the delay before the notification disappears.
setDelayMsec
public void setDelayMsec(int delayMsec)
- Parameters:
delayMsec
- the desired delay in msec, -1 to require the user to click the message
Sets the delay before the notification disappears.
setStyleName
public void setStyleName(String styleName)
- Parameters:
styleName
- The desired style name.
Sets the style name for the notification message.
getStyleName
public String getStyleName()
- Returns:
Gets the style name for the notification message.
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed)
- Parameters:
htmlContentAllowed
- true if the texts are used as html, false if used as plain text
Sets whether html is allowed in the caption and description. If set to true, the texts are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the texts are passed to the browser as plain text.
isHtmlContentAllowed
public boolean isHtmlContentAllowed()
- Returns:
- true if the texts are used as html, false if used as plain text
- See Also:
setHtmlContentAllowed(boolean)
Checks whether caption and description are interpreted as html or plain text.