com.vaadin.flow.component.page.
Interface WebStorage
All Superinterfaces:
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 ClassesModifier and TypeInterfaceDescriptionstatic interface
This callback is notified after the value has been retrieved from the client side.
static enum
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic void
clear()
Clears all values from the Storage.localStorage
static void
clear
(WebStorage.Storage storage) Clears the given storage.
static void
clear
(UI ui, WebStorage.Storage storage) Clears the given storage.
static CompletableFuture<String>
getItem
(WebStorage.Storage storage, String key) Asynchronously gets an item from the given storage.
static void
getItem
(WebStorage.Storage storage, String key, WebStorage.Callback callback) Asynchronously gets an item from the given storage.
static CompletableFuture<String>
getItem
(UI ui, WebStorage.Storage storage, String key) Asynchronously gets an item from the given storage.
static void
getItem
(UI ui, WebStorage.Storage storage, String key, WebStorage.Callback callback) Asynchronously gets an item from the given storage.
static CompletableFuture<String>
Asynchronously gets an item from the local storage.
static void
getItem
(String key, WebStorage.Callback callback) Asynchronously gets an item from the local storage.
static void
removeItem
(WebStorage.Storage storage, String key) Removes the value associated by the given key from the provided storage type
static void
removeItem
(UI ui, WebStorage.Storage storage, String key) Removes the value associated by the given key from the provided storage type
static void
removeItem
(String key) Removes the value associated by the given key from the Storage.localStorage
static void
setItem
(WebStorage.Storage storage, String key, String value) Sets given key-value pair to given storage type
static void
setItem
(UI ui, WebStorage.Storage storage, String key, String value) Sets given key-value pair to given storage type
static void
Sets given key-value pair to Storage.localStorage
-
Method Details
-
setItem
Sets given key-value pair to Storage.localStorage
Parameters:
key
- the keyvalue
- the value -
setItem
Sets given key-value pair to given storage type
Parameters:
storage
- the storage typekey
- the keyvalue
- the value -
setItem
Sets given key-value pair to given storage type
Parameters:
ui
- the UI for which the storage is related tostorage
- the storage typekey
- the keyvalue
- the value -
removeItem
Removes the value associated by the given key from the Storage.localStorage
Parameters:
key
- the key to be deleted -
removeItem
Removes the value associated by the given key from the provided storage type
Parameters:
storage
- the storage type from which the value will be removedkey
- the key to be deleted -
removeItem
Removes the value associated by the given key from the provided storage type
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
static void clear()Clears all values from the Storage.localStorage
-
clear
Clears the given storage.
Parameters:
storage
- the storage -
clear
Clears the given storage.
Parameters:
ui
- the UI for which the storage is related tostorage
- the storage -
getItem
Asynchronously gets an item from the local storage.
Parameters:
key
- the key for which the value will be fetchedcallback
- the callback that gets the value once transferred from the client side ornull
if the value was not available. -
getItem
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 ornull
if the value was not available. -
getItem
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 ornull
if the value was not available. -
getItem
Asynchronously gets an item from the local storage.
It is not possible to synchronously wait for the result of the execution while holding the session lock since the request handling thread that makes the result available will also need to lock the session.
SeePendingJavaScriptResult.toCompletableFuture(java.lang.Class<T>)
for more information.Parameters:
key
- the key for which the value will be fetchedReturns:
a CompletableFuture that will be completed with the value once transferred from the client side or
null
if the value was not available. -
getItem
Asynchronously gets an item from the given storage.
It is not possible to synchronously wait for the result of the execution while holding the session lock since the request handling thread that makes the result available will also need to lock the session.
SeePendingJavaScriptResult.toCompletableFuture(java.lang.Class<T>)
for more information.Parameters:
storage
- the storagekey
- the key for which the value will be fetchedReturns:
a CompletableFuture that will be completed with the value once transferred from the client side or
null
if the value was not available. -
getItem
Asynchronously gets an item from the given storage.
It is not possible to synchronously wait for the result of the execution while holding the session lock since the request handling thread that makes the result available will also need to lock the session.
SeePendingJavaScriptResult.toCompletableFuture(java.lang.Class<T>)
for more information.Parameters:
ui
- the UI for which the storage is related tostorage
- the storagekey
- the key for which the value will be fetchedReturns:
a CompletableFuture that will be completed with the value once transferred from the client side or
null
if the value was not available.
-