Feature proposal
EasyRowAction.withConfirmation(...) currently accepts static strings only:
public EasyRowAction<T> withConfirmation(String message)
public EasyRowAction<T> withConfirmation(String title, String message)
There is no way to derive the confirmation text from the row item, so the most common phrasing for a
destructive action — "Are you sure you want to delete John Smith?" — cannot be expressed. The
message has to stay generic ("Are you sure you want to delete this item?"), or the developer has to
abandon withConfirmation altogether and open a ConfirmDialog by hand inside the action handler.
Rolling your own dialog means losing what EasyRowAction already does for you:
- the
confirmPending guard that stops dialogs from stacking on rapid clicks;
- re-checking
visibleWhen / enabledWhen at confirm time, not just at click time;
- the Vaadin 24 / 25 compatibility shim around
ConfirmDialog.addOpenedChangeListener.
This is the same gap that was already closed for tooltips, which offer both a static and a
row-derived form (tooltip(String) / tooltip(ValueProvider<T, String>)).
Describe solution expectations
Add ValueProvider overloads mirroring the tooltip pair:
public EasyRowAction<T> withConfirmation(ValueProvider<T, String> messageProvider)
public EasyRowAction<T> withConfirmation(String title, ValueProvider<T, String> messageProvider)
public EasyRowAction<T> withConfirmation(ValueProvider<T, String> titleProvider,
ValueProvider<T, String> messageProvider)
Usage:
grid.addRowAction("Delete", VaadinIcon.TRASH, this::delete)
.withConfirmation("Delete person",
person -> "Are you sure you want to delete " + person.getFullName() + "?");
The three signatures do not collide with the existing (String) / (String, String) pair, so this
is source- and binary-compatible.
Implementation looks small, because the dialog is already built lazily at click time:
confirmDialogSupplier (a SerializableSupplier<ConfirmDialog>, field declared at
EasyRowAction.java:129) is only invoked from execute(T item), where the row item is already in
scope. Changing it to a SerializableFunction<T, ConfirmDialog> and calling .apply(item) instead
of .get() is enough to make the whole dialog item-aware.
- The private builder at
EasyRowAction.java:209 becomes provider-based, and the existing String
overloads delegate to it through Constant.of(...) — exactly the way tooltip(String) delegates
today.
null title should keep meaning "no header", as it does now via
withConfirmation(String message) → withConfirmation(null, message).
ValueProvider is Serializable, so this stays consistent with the add-on's serialization
requirements.
Whether the confirm/cancel button labels should also become row-derived is probably not worth it —
they are not item-dependent in practice — but the private 4-arg builder would support it for free if
that changes.
Additional information
References in src/main/java/com/flowingcode/vaadin/addons/easygrid/actions/EasyRowAction.java
(master):
| What |
Line |
tooltip(String) — the precedent, delegates via Constant.of |
170 |
tooltip(ValueProvider<T, String>) — the precedent |
182 |
withConfirmation(String message) |
194 |
withConfirmation(String title, String message) |
205 |
private withConfirmation(title, message, confirmText, cancelText) builder |
209 |
confirmDialogSupplier field |
129 |
execute(T item) — where the dialog is built, item in scope |
270 |
RowActionsDynamicDemo would be the natural place to show a per-row confirmation message alongside
the existing dynamic tooltip / visibleWhen / enabledWhen examples.
Feature proposal
EasyRowAction.withConfirmation(...)currently accepts static strings only:There is no way to derive the confirmation text from the row item, so the most common phrasing for a
destructive action — "Are you sure you want to delete John Smith?" — cannot be expressed. The
message has to stay generic ("Are you sure you want to delete this item?"), or the developer has to
abandon
withConfirmationaltogether and open aConfirmDialogby hand inside the action handler.Rolling your own dialog means losing what
EasyRowActionalready does for you:confirmPendingguard that stops dialogs from stacking on rapid clicks;visibleWhen/enabledWhenat confirm time, not just at click time;ConfirmDialog.addOpenedChangeListener.This is the same gap that was already closed for tooltips, which offer both a static and a
row-derived form (
tooltip(String)/tooltip(ValueProvider<T, String>)).Describe solution expectations
Add
ValueProvideroverloads mirroring thetooltippair:Usage:
The three signatures do not collide with the existing
(String)/(String, String)pair, so thisis source- and binary-compatible.
Implementation looks small, because the dialog is already built lazily at click time:
confirmDialogSupplier(aSerializableSupplier<ConfirmDialog>, field declared atEasyRowAction.java:129) is only invoked fromexecute(T item), where the row item is already inscope. Changing it to a
SerializableFunction<T, ConfirmDialog>and calling.apply(item)insteadof
.get()is enough to make the whole dialog item-aware.EasyRowAction.java:209becomes provider-based, and the existingStringoverloads delegate to it through
Constant.of(...)— exactly the waytooltip(String)delegatestoday.
nulltitle should keep meaning "no header", as it does now viawithConfirmation(String message)→withConfirmation(null, message).ValueProviderisSerializable, so this stays consistent with the add-on's serializationrequirements.
Whether the confirm/cancel button labels should also become row-derived is probably not worth it —
they are not item-dependent in practice — but the private 4-arg builder would support it for free if
that changes.
Additional information
References in
src/main/java/com/flowingcode/vaadin/addons/easygrid/actions/EasyRowAction.java(master):
tooltip(String)— the precedent, delegates viaConstant.oftooltip(ValueProvider<T, String>)— the precedentwithConfirmation(String message)withConfirmation(String title, String message)withConfirmation(title, message, confirmText, cancelText)builderconfirmDialogSupplierfieldexecute(T item)— where the dialog is built, item in scopeRowActionsDynamicDemowould be the natural place to show a per-row confirmation message alongsidethe existing dynamic tooltip /
visibleWhen/enabledWhenexamples.