Class CookieConsent

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.cookieconsent.CookieConsent
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

@Tag("vaadin-cookie-consent") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.10.0-alpha1") @NpmPackage(value="@vaadin/cookie-consent",version="24.10.0-alpha1") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/cookie-consent/src/vaadin-cookie-consent.js") @JsModule("./cookieConsentConnector.js") @Deprecated(since="24.9.0", forRemoval=true) public class CookieConsent extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasStyle
Deprecated, for removal: This API element is subject to removal in a future version.
CookieConsent is deprecated and will be removed without a replacement in Vaadin 25.
Cookie Consent is a component for showing a cookie consent banner the first time a user visits the application, until the banner is dismissed.

By default, the banner is shown at the top of the screen with a predefined text, a link to cookiesandyou.com which explains what cookies are, and a consent button.

Cookie Consent is fully customizable. You can customize the message, the "Learn More" link, the "Dismiss" button, as well as the component’s position.

Author:
Vaadin Ltd
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Position of the banner.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a banner with default values.
    CookieConsent(String message, String dismissLabel, String learnMoreLabel, String learnMoreLink, CookieConsent.Position position)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a banner with the specified data
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.dom.Style
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    setCookieName(String cookieName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the name of the cookie to remember that the user has consented.
    void
    setDismissLabel(String dismissLabel)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the dismiss/consent button's text
    void
    setLearnMoreLabel(String learnMoreLabel)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the label of the 'learn more' link
    void
    setLearnMoreLink(String learnMoreLink)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the URL of the 'learn more' link
    void
    setMessage(String message)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the consent message to show in the banner.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the position of the banner on the page.

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • CookieConsent

      public CookieConsent()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a banner with default values.
    • CookieConsent

      public CookieConsent(String message, String dismissLabel, String learnMoreLabel, String learnMoreLink, CookieConsent.Position position)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a banner with the specified data
      Parameters:
      message - The message to show in the banner.
      dismissLabel - The text to show on the dismiss/consent button.
      learnMoreLabel - The text to show on the 'learn more' link.
      learnMoreLink - The URL the 'learn more' link should open.
      position - Determines the position of the banner.
  • Method Details

    • setMessage

      public void setMessage(String message)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the consent message to show in the banner.
      Parameters:
      message - The message to show in the banner.
    • setDismissLabel

      public void setDismissLabel(String dismissLabel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the dismiss/consent button's text
      Parameters:
      dismissLabel - The text of the button.
    • setLearnMoreLabel

      public void setLearnMoreLabel(String learnMoreLabel)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the label of the 'learn more' link
      Parameters:
      learnMoreLabel - The text to show on the 'learn more' link.
    • setLearnMoreLink

      public void setLearnMoreLink(String learnMoreLink)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the URL of the 'learn more' link
      Parameters:
      learnMoreLink - The URL the 'learn more' link should open.
    • setPosition

      public void setPosition(CookieConsent.Position position)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the position of the banner on the page.
      Parameters:
      position - Determines the position of the banner.
      Throws:
      NullPointerException - if position is null.
    • setCookieName

      public void setCookieName(String cookieName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the name of the cookie to remember that the user has consented. This rarely needs to be changed.
      Parameters:
      cookieName - The name of the cookie.
    • getStyle

      public com.vaadin.flow.dom.Style getStyle()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getStyle in interface com.vaadin.flow.component.HasStyle
      Throws:
      UnsupportedOperationException - CookieConsent does not support adding styles
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      onAttach in class com.vaadin.flow.component.Component