Class ServerSideColumnPreferenceStorage
java.lang.Object
org.vaadin.addons.antlerflow.grid.columns.storage.ServerSideColumnPreferenceStorage
- All Implemented Interfaces:
Serializable, ColumnPreferenceStorage
- Direct Known Subclasses:
InMemoryColumnPreferenceStorage, JdbcColumnPreferenceStorage
public abstract class ServerSideColumnPreferenceStorage
extends Object
implements ColumnPreferenceStorage
Base class for storages that keep preferences on the server, per user (a database, a cache, a
REST service). Subclasses implement three synchronous methods; this class resolves the current
user and turns failures into a logged warning so the grid falls back to its default columns.
When the user id supplier returns null or blank (an anonymous visitor), nothing is
read or written.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServerSideColumnPreferenceStorage(com.vaadin.flow.function.SerializableSupplier<String> userIdSupplier) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear(ColumnPreferenceContext context) Removes the preference stored under the context's key, if any.protected abstract voidDeletes the preference; a missing preference is not an error.final voidload(ColumnPreferenceContext context, com.vaadin.flow.function.SerializableConsumer<Map<String, Boolean>> onLoaded) Loads the preference and passes it toonLoaded, possibly later (for example after a browser round trip).Reads the stored preference; empty when none is stored.static com.vaadin.flow.function.SerializableSupplier<String> Returns a user id supplier reading the authenticated principal of the current Vaadin request (HttpServletRequest#getUserPrincipal()), which Spring Security and servlet container security both populate.final voidsave(ColumnPreferenceContext context, Map<String, Boolean> visibility) Stores the preference, replacing any previous one under the same key.protected abstract voidInserts or replaces the preference.
-
Constructor Details
-
ServerSideColumnPreferenceStorage
protected ServerSideColumnPreferenceStorage(com.vaadin.flow.function.SerializableSupplier<String> userIdSupplier) - Parameters:
userIdSupplier- returns the current user's stable id (for example the login name); called on the UI thread while handling a request
-
-
Method Details
-
requestPrincipalName
Returns a user id supplier reading the authenticated principal of the current Vaadin request (HttpServletRequest#getUserPrincipal()), which Spring Security and servlet container security both populate. Anonymous requests yieldnull. -
read
-
write
-
delete
-
load
public final void load(ColumnPreferenceContext context, com.vaadin.flow.function.SerializableConsumer<Map<String, Boolean>> onLoaded) Description copied from interface:ColumnPreferenceStorageLoads the preference and passes it toonLoaded, 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.- Specified by:
loadin interfaceColumnPreferenceStorage
-
save
Description copied from interface:ColumnPreferenceStorageStores the preference, replacing any previous one under the same key.- Specified by:
savein interfaceColumnPreferenceStorage
-
clear
Description copied from interface:ColumnPreferenceStorageRemoves the preference stored under the context's key, if any.- Specified by:
clearin interfaceColumnPreferenceStorage
-