Package com.vaadin.event
Class Action
- java.lang.Object
-
- com.vaadin.event.Action
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ShortcutAction
public class Action extends Object implements Serializable
Implements the action framework. This class contains subinterfaces for action handling and listing, and for action handler registrations and unregistration.- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAction.ContainerInterface implemented by all components where actions can be registered.static interfaceAction.HandlerInterface implemented by classes who wish to handle actions.static interfaceAction.ListenerAn Action that implements this interface can be added to an Action.Notifier (or NotifierProxy) via theaddAction()-method, which in many cases is easier than implementing the Action.Handler interface.static interfaceAction.NotifierAction.Containers implementing this support an easier way of adding single Actions than the more involved Action.Handler.static interfaceAction.ShortcutNotifier
-
Constructor Summary
Constructors Constructor Description Action(String caption)Constructs a new action with the given caption.Action(String caption, boolean allowHTML)Constructs a new action with the given caption and caption content mode.Action(String caption, boolean allowHTML, Resource icon)Constructs a new action with the given caption, caption content mode and icon.Action(String caption, Resource icon)Constructs a new action with the given caption string and icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCaption()Returns the action's caption.ResourcegetIcon()Returns the action's icon.voidsetCaption(String caption)Sets the caption.voidsetCaption(String caption, boolean allowHTML)Sets the caption.voidsetIcon(Resource icon)Sets the icon.
-
-
-
Constructor Detail
-
Action
public Action(String caption)
Constructs a new action with the given caption. The caption will be treated as text. Any HTML content in the caption will be stripped, after which the remaining string will be set. If you wish to retain HTML content as part of the caption string, use theAction(String, boolean)constructor.- Parameters:
caption- the caption for the new action.- See Also:
Action(String, boolean),setCaption(String, boolean)
-
Action
public Action(String caption, boolean allowHTML)
Constructs a new action with the given caption and caption content mode.
Note that when allowing the HTML content the developer is responsible for ensuring that no harmful HTML is present in the caption string, as the caption may be passed directly into client DOM. Using untrusted input in the caption together with HTML mode can create Cross-site Scripting (XSS) vulnerabilities.- Parameters:
caption- the caption for the new action.allowHTML- If false, the caption string is cleaned and all HTML content is removed. if true, the caption string is passed through as-is and any HTML that may be in it may get transmitted to the client-side.- Since:
- 7.7.50
- See Also:
setCaption(String, boolean)
-
Action
public Action(String caption, Resource icon)
Constructs a new action with the given caption string and icon. The caption will be treated as text. Any HTML content in the caption will be stripped, after which the remaining string will be set. If you wish to retain HTML content as part of the caption string, use the#Action(String, ContentMode, Resource)constructor.- Parameters:
caption- the caption for the new action.icon- the icon for the new action.- See Also:
Action#Action(String, ContentMode, Resource),Action#setCaption(String, ContentMode)
-
Action
public Action(String caption, boolean allowHTML, Resource icon)
Constructs a new action with the given caption, caption content mode and icon.
Note that when allowing the HTML content the developer is responsible for ensuring that no harmful HTML is present in the caption string, as the caption may be passed directly into client DOM. Using untrusted input in the caption together with HTML mode can create Cross-site Scripting (XSS) vulnerabilities.- Parameters:
caption- the caption for the new action.allowHTML- If false, the caption string is cleaned and all HTML content is removed. if true, the caption string is passed through as-is and any HTML that may be in it may get transmitted to the client-side.- Since:
- 7.7.50
- See Also:
setCaption(String, boolean)
-
-
Method Detail
-
getCaption
public String getCaption()
Returns the action's caption.- Returns:
- the action's caption as a
String.
-
getIcon
public Resource getIcon()
Returns the action's icon.- Returns:
- the action's Icon.
-
setCaption
public void setCaption(String caption)
Sets the caption. Note, that any HTML in the caption will be stripped. To allow HTML content in the title, use#setCaption(String, ContentMode).- Parameters:
caption- the caption to set.
-
setCaption
public void setCaption(String caption, boolean allowHTML)
Sets the caption.If {@param allowHTML} is false, any HTML tags in the string will be stripped and what remains of the text will be set as the caption. If it is true, the string is passed as-is.
Note that when allowing HTML content the developer is responsible for ensuring that no harmful HTML is present in the caption string, as the caption may be passed directly into client DOM. Using untrusted input in the caption together with HTML mode can create Cross-site Scripting (XSS) vulnerabilities.
- Parameters:
caption- the caption to set.allowHTML- If false, the caption string is cleaned and all HTML content is removed. if true, the caption string is passed through as-is and any HTML that may be in it may get transmitted to the client-side.- Since:
- 7.7.50
-
setIcon
public void setIcon(Resource icon)
Sets the icon.- Parameters:
icon- the icon to set.
-
-