You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.component.page.

Interface WebStorage

All Superinterfaces:

Serializable

public interface WebStorage extends Serializable

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.

  • Method Details

    • setItem

      static void setItem(String key, String value)

      Sets given key-value pair to Storage.localStorage

      Parameters:

      key - the key

      value - the value

    • setItem

      static void setItem(WebStorage.Storage storage, String key, String value)

      Sets given key-value pair to given storage type

      Parameters:

      storage - the storage type

      key - the key

      value - the value

    • setItem

      static void setItem(UI ui, WebStorage.Storage storage, String key, String value)

      Sets given key-value pair to given storage type

      Parameters:

      ui - the UI for which the storage is related to

      storage - the storage type

      key - the key

      value - the value

    • removeItem

      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

      static void removeItem(WebStorage.Storage storage, String key)

      Removes the value associated by the given key from the provided storage type

      Parameters:

      storage - the storage type from which the value will be removed

      key - the key to be deleted

    • removeItem

      static void removeItem(UI ui, WebStorage.Storage storage, String key)

      Removes the value associated by the given key from the provided storage type

      Parameters:

      ui - the UI for which the storage is related to

      storage - the storage type from which the value will be removed

      key - the key to be deleted

    • clear

      static void clear()

      Clears all values from the Storage.localStorage

    • clear

      static void clear(WebStorage.Storage storage)

      Clears the given storage.

      Parameters:

      storage - the storage

    • clear

      static void clear(UI ui, WebStorage.Storage storage)

      Clears the given storage.

      Parameters:

      ui - the UI for which the storage is related to

      storage - the storage

    • getItem

      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 fetched

      callback - the callback that gets the value once transferred from the client side

    • getItem

      static void getItem(WebStorage.Storage storage, String key, WebStorage.Callback callback)

      Asynchronously gets an item from the given storage

      Parameters:

      storage - the storage

      key - the key for which the value will be fetched

      callback - the callback that gets the value once transferred from the client side

    • getItem

      static void getItem(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 to

      storage - the storage

      key - the key for which the value will be fetched

      callback - the callback that gets the value once transferred from the client side