Class BrowserCookie

java.lang.Object
org.vaadin.firitin.util.BrowserCookie

public class BrowserCookie extends Object
A helper that provides access to browser cookies.
Author:
Matti Tahvonen
  • Constructor Details

    • BrowserCookie

      public BrowserCookie()
  • Method Details

    • setCookie

      public static void setCookie(String key, String value)
    • setCookie

      public static void setCookie(String key, String value, LocalDateTime expirationTime)
    • setCookie

      public static void setCookie(String key, String value, String path, LocalDateTime expirationTime)
    • setCookie

      public static void setCookie(String key, String value, String path)
    • detectCookieValue

      public static void detectCookieValue(String key, BrowserCookie.Callback callback)
    • bindValueToCookie

      public static <E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, V> void bindValueToCookie(com.vaadin.flow.component.HasValue<E,V> field, String name, BrowserCookie.Callback cb)
      Binds a HasValue<V> to a cookie that lives for a month. The cookies value is updated via a ValueChangeListener.
      Type Parameters:
      E - the type of the value change event fired by field
      V - The value-type of the HasValue<>
      Parameters:
      field - The HasValue<V> that gets bound.
      name - The name of the cookie
      cb - A BrowserCookie.Callback that gets called with the actual value of the cookie. The value is guaranteed to be not null.
      Throws:
      IllegalArgumentException - if field or name are null or if name is empty.
    • bindValueToCookie

      public static void bindValueToCookie(com.vaadin.flow.component.HasValue<? extends com.vaadin.flow.component.HasValue.ValueChangeEvent<String>,String> field, String name)
      Binds a HasValue<String> to a cookie that lives for a month. The cookies value is updated via a ValueChangeListener. Its crrent value is copied into the HasValue<String>.
      Parameters:
      field - The HasValue<String> that gets bound.
      name - The name of the cookie
      Throws:
      IllegalArgumentException - if field or name are null or if name is empty.