Package org.vaadin.firitin.util
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBrowserCookie.Callback
-
Constructor Summary
Constructors Constructor Description BrowserCookie()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbindValueToCookie(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.static <E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<V>,V>
voidbindValueToCookie(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.static voiddetectCookieValue(String key, BrowserCookie.Callback callback)static voidsetCookie(String key, String value)static voidsetCookie(String key, String value, String path)static voidsetCookie(String key, String value, String path, LocalDateTime expirationTime)static voidsetCookie(String key, String value, LocalDateTime expirationTime)
-
-
-
Method Detail
-
setCookie
public static void setCookie(String key, String value, LocalDateTime expirationTime)
-
setCookie
public static void setCookie(String key, String value, String path, LocalDateTime expirationTime)
-
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:
V- The value-type of the HasValue<>E- the type of the value change event fired by field- Parameters:
field- The HasValue<V> that gets bound.name- The name of the cookiecb- 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.
-
-