Class 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
    • 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 the Action(String, ContentMode) constructor.
        Parameters:
        caption - the caption for the new action.
        See Also:
        Action(String, ContentMode), setCaption(String, ContentMode)
      • Action

        public Action​(String caption,
                      ContentMode contentMode)
        Constructs a new action with the given caption and caption content mode.
        Note that when using the HTML content mode 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.
        contentMode - the content mode for the action title. Valid values are ContentMode.TEXT, and ContentMode.HTML. Any other value causes an IllegalArgumentException to be thrown.
        Since:
        8.30
        See Also:
        setCaption(String, ContentMode)
      • Action

        public Action​(String caption,
                      ContentMode contentMode,
                      Resource icon)
        Constructs a new action with the given caption, caption content mode and icon.
        Note that when using the HTML content mode 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.
        contentMode - the content mode for the action title. Valid values are ContentMode.TEXT, and ContentMode.HTML. Any other value causes an IllegalArgumentException to be thrown.
        Since:
        8.30
        See Also:
        setCaption(String, ContentMode)
    • 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,
                               ContentMode contentMode)
        Sets the caption.

        If the content mode is ContentMode.TEXT, any HTML tags in the string will be stripped. If the content mode is ContentMode.HTML, the string is passed as-is. Any other value for ContentMode causes an IllegalArgumentException to be thrown.
        Note that when using the HTML content mode 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.
        contentMode - the content mode for the action title. Valid values are ContentMode.TEXT and ContentMode.HTML. Any other value causes an IllegalArgumentException to be thrown.
        Since:
        8.30
      • setIcon

        public void setIcon​(Resource icon)
        Sets the icon.
        Parameters:
        icon - the icon to set.