Package org.vaadin.firitin.util
Class WebStorage
- java.lang.Object
-
- org.vaadin.firitin.util.WebStorage
-
public class WebStorage extends Object
Wrapper for similarly named Browser API. WebStorage may be handy to save some data that you want to be stored on the client side, instead of e.g. database on the server. An example could be certain UI settings that the same users might want to have set differently based on their device.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWebStorage.Callbackstatic classWebStorage.Storage
-
Constructor Summary
Constructors Constructor Description WebStorage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclear()Clears all values from the Storage.localStoragestatic voidclear(com.vaadin.flow.component.UI ui, WebStorage.Storage storage)Clears the given storage.static voidclear(WebStorage.Storage storage)Clears the given storage.static voidgetItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key, WebStorage.Callback callback)Asynchronously gets an item from the given storagestatic voidgetItem(String key, WebStorage.Callback callback)Asynchronously gets an item from the Storage.localStoragestatic voidgetItem(WebStorage.Storage storage, String key, WebStorage.Callback callback)Asynchronously gets an item from the given storagestatic voidremoveItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key)Removes the value associated by the given key from the Storage.localStoragestatic voidremoveItem(String key)Removes the value associated by the given key from the Storage.localStoragestatic voidremoveItem(WebStorage.Storage storage, String key)Removes the value associated by the given key from the Storage.localStoragestatic voidsetItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key, String value)Sets given key-value pair to give storage typestatic voidsetItem(String key, String value)Sets given key-value pair to Storage.localStoragestatic voidsetItem(WebStorage.Storage storage, String key, String value)Sets given key-value pair to give storage type
-
-
-
Method Detail
-
setItem
public static void setItem(String key, String value)
Sets given key-value pair to Storage.localStorage- Parameters:
key- the keyvalue- the value
-
setItem
public static void setItem(WebStorage.Storage storage, String key, String value)
Sets given key-value pair to give storage type- Parameters:
storage- the storage typekey- the keyvalue- the value
-
setItem
public static void setItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key, String value)Sets given key-value pair to give storage type- Parameters:
ui- the UI for which the storage is related tostorage- the storage typekey- the keyvalue- the value
-
removeItem
public static void removeItem(String key)
Removes the value associated by the given key from the Storage.localStorage- Parameters:
key- the key to be deleted
-
removeItem
public static void removeItem(WebStorage.Storage storage, String key)
Removes the value associated by the given key from the Storage.localStorage- Parameters:
storage- the storage type from which the value will be removedkey- the key to be deleted
-
removeItem
public static void removeItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key)Removes the value associated by the given key from the Storage.localStorage- Parameters:
ui- the UI for which the storage is related tostorage- the storage type from which the value will be removedkey- the key to be deleted
-
clear
public static void clear()
Clears all values from the Storage.localStorage
-
clear
public static void clear(WebStorage.Storage storage)
Clears the given storage.- Parameters:
storage- the storage
-
clear
public static void clear(com.vaadin.flow.component.UI ui, WebStorage.Storage storage)Clears the given storage.- Parameters:
ui- the UI for which the storage is related tostorage- the storage
-
getItem
public static void getItem(String key, WebStorage.Callback callback)
Asynchronously gets an item from the Storage.localStorage- Parameters:
key- the key for which the value will be fetchedcallback- the callback that gets the value once transferred from the client side
-
getItem
public static void getItem(WebStorage.Storage storage, String key, WebStorage.Callback callback)
Asynchronously gets an item from the given storage- Parameters:
storage- the storagekey- the key for which the value will be fetchedcallback- the callback that gets the value once transferred from the client side
-
getItem
public static void getItem(com.vaadin.flow.component.UI ui, WebStorage.Storage storage, String key, WebStorage.Callback callback)Asynchronously gets an item from the given storage- Parameters:
ui- the UI for which the storage is related tostorage- the storagekey- the key for which the value will be fetchedcallback- the callback that gets the value once transferred from the client side
-
-