Skip to content

ConfirmDialog

A pre-built confirmation dialog with a header, body text, and confirm/reject/cancel buttons wired to server actions.

ConfirmDialog.builder()
.header("Are you sure?")
.content(new Text("This will permanently delete the record."))
.confirmText("Yes, delete")
.confirmActionId("confirm_delete")
.build()
PropertyTypeDefaultDescription
headerString—Dialog header text
contentComponent—Body content
canCancelbooleanfalseShows a Cancel button
canRejectbooleanfalseShows a Reject button
rejectTextString—Label for the Reject button
confirmTextString—Label for the Confirm button
openedConditionString"true"Expression over the state controlling visibility (open when absent)
confirmActionIdString—Action fired when the user confirms
rejectActionIdString—Action fired when the user rejects
cancelActionIdString—Action fired when the user cancels
styleString—Inline CSS
cssClassesString—CSS class names
ConfirmDialog.builder()
.header("Submit order?")
.content(new Text("You have 3 items in your cart totalling €89.97."))
.confirmText("Place order")
.confirmActionId("place_order")
.rejectText("Save for later")
.rejectActionId("save_cart")
.canReject(true)
.canCancel(true)
.cancelActionId("dismiss")
.build()

An action can return a ConfirmDialog: it opens over the page (like a Dialog), closes once the user picks a button, and the picked button’s action runs on the view that returned it — a plain public method is enough, it does not need to be listed anywhere else.

@Button
public ConfirmDialog archive() {
return ConfirmDialog.builder()
.header("Archive 3 orders?")
.content(new Text("They leave the active list."))
.confirmText("Archive")
.confirmActionId("doArchive")
.canCancel(true)
.build();
}
public Message doArchive() { /* … */ return Message.success("Archived"); }
@Override
public Object handleAction(String actionId, HttpRequest request) {
return switch (actionId) {
case "place_order" -> { placeOrder(); yield new State(this); }
case "save_cart" -> { saveCart(); yield new State(this); }
default -> new State(this);
};
}