Skip to content

Saved views

Status: ✅ Implemented

Power users return to the same slices of data every day: “my pending invoices”, “arrivals this week”, “high-value bookings”. Rebuilding the filter set every time is a tax; bookmarking URLs is invisible and personal-toolbar-dependent. Saved views make the condition set a first-class, named thing on the listing itself.

Every crud/listing’s smart search bar has a bookmark button on the right. It opens the views panel:

  • Save current view as… — snapshots the whole condition set (keyword chip, filter values, range bounds, multi-selects) and the listing’s layout — its sort, its columns (order and hidden ones) and its page size — under a name. Saving an existing name replaces it.
  • Click a view — clears the current conditions, applies the view’s and re-runs the search.
  • ★ — marks the view as the listing’s default: the listing opens with it applied whenever the URL carries no explicit filter params (an explicitly shared/bookmarked URL always wins). Starring again clears the default.
  • ✎ — renames the view; its conditions, layout and ★ stay.
  • ✕ — deletes the view.

No annotations needed — it works on every listing that shows the smart search bar, in every renderer.

On the server, for a signed-in user (the default since 3.0, @Experimental). The views follow the person: another browser, another computer, the phone app and the desktop app all show the same ones. They are kept per user and per listing (its route), and nobody else can read or change them — the owner is always the signed-in caller, never something the browser sends.

In the browser, when the user is anonymous or the app chooses so (mateu.saved-views.storage=browser): localStorage, key mateu-saved-views, per listing route and per origin. The React Native app keeps them on the device, per UI and per listing; the desktop app in the IDE’s settings.

Kept on the server, the renderers hold them only in memory — never in localStorage — so on a shared computer the next person does not see them.

A filter can be renamed or removed after a view was saved. Applying that view keeps the conditions the listing still has and tells the user which ones were dropped (“Some conditions of “Big orders” no longer apply: region”), in the user’s language, instead of silently showing other rows.

The layout travels inside the same values, under reserved keys, and only when it is not the listing’s default — so a view saved before 3.0.18 is still the “active” one when nothing was reordered:

KeyValue
_sort["total:descending", "date:ascending"]
_columnOrder["total", "customer"]
_hiddenColumns["notes"]
_pageSize50

Applying a view replaces the current layout (a view without one brings the listing’s defaults back). A sort or a column of a field the listing no longer has is dropped and named, like a filter. What each renderer applies: Vaadin (Lumo and Aura), Primer, UI5, SLDS and the phone app — all four; Redwood — sort and columns (its page size is the listing’s own); the desktop app — sort and page size (it has no column chooser).

The client never decides what is valid. The server refuses: an anonymous caller (403), a missing or too long name (100 characters), a view with no conditions, more than 100 conditions, values that are not plain text, numbers, booleans or lists of them, more than 50 views per listing — with a message the renderer shows as it came.

The default store keeps the views in memory: fine for a single instance and for trying it out, but they are lost when the app restarts (Mateu warns once at startup). For real use, give Mateu a store.

Any bean implementing io.mateu.uidl.interfaces.SavedViewStore (list, save, delete, setPreferred; renaming needs nothing more — Mateu does it with those). Mateu ships one over JDBC in its own optional module — add it only if you want it; nothing in Mateu brings a database driver:

<dependency>
<groupId>io.mateu</groupId>
<artifactId>mateu-saved-views-jdbc</artifactId>
</dependency>
@Bean
SavedViewStore savedViews(DataSource dataSource) {
var store = new JdbcSavedViewStore(dataSource); // table mateu_saved_views
store.createTableIfMissing(); // or create it with your migrations
return store;
}

store.ddl(product) gives the CREATE TABLE for PostgreSQL, MySQL/MariaDB, SQL Server, Oracle and H2 if you prefer to put it in Flyway/Liquibase. Only mateu-uidl and the JDK’s java.sql are needed; the driver is yours.

SettingWhat it does
mateu.saved-views.storage = server (default) | browser — .NET MateuOptions.SavedViewsStorage / MATEU_SAVED_VIEWS_STORAGE, Python add_mateu(saved_views="browser")Where the views are kept. browser keeps the pre-3.0 behaviour.

Additive:

  • AppDto.savedViewsOnServer — true when the views of this caller are kept on the server;
  • app-level actions _saved-views-list|save|rename|delete|default with {scope, name, values, isDefault} (rename takes {scope, name, newName}), each answering data._savedViews = [{name, values, isDefault}].

A renderer that does not know the flag keeps the views in the browser, as before.

demo/demo-bank (port 8650): Movements filters by kind, date and amount. Save a view, star it, open the listing in another browser — it opens with the view. The demo keeps the views in H2 through mateu-saved-views-jdbc (SavedViewsConfig), so they survive a restart.

See it live in the Explorer: Saved views & column chooser