Interface ColumnPreferenceStorage

All Superinterfaces:
Serializable
All Known Implementing Classes:
BrowserColumnPreferenceStorage, InMemoryColumnPreferenceStorage, JdbcColumnPreferenceStorage, ServerSideColumnPreferenceStorage

public interface ColumnPreferenceStorage extends Serializable
Stores a user's column visibility preference for an AdvancedGrid.

A preference is a map of column id to visibility (see ColumnPreferences#columnId), kept under a key that identifies one grid (see ColumnPreferenceContext.key()).

Ready-made implementations:

To store elsewhere (a REST service, Redis, a JPA repository), extend ServerSideColumnPreferenceStorage for any synchronous server-side destination, or implement this interface directly for asynchronous ones.

Implementations must not throw from these methods for storage failures: a preference is a convenience, and the grid must keep working with its default columns when storage is unavailable. Log the failure and report an empty preference instead.

  • Method Details

    • load

      void load(ColumnPreferenceContext context, com.vaadin.flow.function.SerializableConsumer<Map<String,Boolean>> onLoaded)
      Loads the preference and passes it to onLoaded, possibly later (for example after a browser round trip). Pass an empty map when nothing is stored. Must be called on the UI thread (with the session locked), as the grid applies the result directly.
    • save

      void save(ColumnPreferenceContext context, Map<String,Boolean> visibility)
      Stores the preference, replacing any previous one under the same key.
    • clear

      void clear(ColumnPreferenceContext context)
      Removes the preference stored under the context's key, if any.
    • localStorage

      static ColumnPreferenceStorage localStorage()
      Stores preferences in the browser's localStorage.
    • sessionStorage

      static ColumnPreferenceStorage sessionStorage()
      Stores preferences in the browser's sessionStorage (cleared when the tab closes).