Skip to content

Action

A named action wired to a button or toolbar slot. Used inside Form, Page, Listing, and other containers to register interactions that Mateu routes to your ActionHandler.

@Builder
public record Action(
String id,
boolean background,
boolean validationRequired,
boolean confirmationRequired,
boolean rowsSelectedRequired,
ConfirmationTexts confirmationTexts,
String modalStyle,
String modalTitle,
CustomEvent customEvent,
String href,
String js,
boolean sse,
String fieldsToValidate,
boolean bubble) {}
PropertyTypeDefaultDescription
idStringAction identifier — passed to ActionHandler.handleAction()
backgroundbooleanfalseRun the action without blocking the UI
validationRequiredbooleanfalseValidate the form before executing
confirmationRequiredbooleanfalseShow a confirmation dialog before executing
rowsSelectedRequiredbooleanfalseRequire at least one row selected in a grid
confirmationTextsConfirmationTextsTexts for the confirmation dialog
modalStyleStringInline CSS for the confirmation modal
modalTitleStringTitle of the confirmation modal
customEventCustomEventCustom browser event to fire on completion
hrefStringNavigate to this URL instead of calling a handler
jsStringExecute JavaScript on the client side
ssebooleanfalseStream results via SSE
fieldsToValidateStringComma-separated field IDs to validate
bubblebooleanfalseBubble the result to the parent component
Action.builder()
.id("save")
.validationRequired(true)
.build()
Action.builder()
.id("delete")
.confirmationRequired(true)
.confirmationTexts(ConfirmationTexts.builder()
.title("Delete record")
.message("This cannot be undone. Continue?")
.confirmText("Delete")
.denyText("Cancel")
.build())
.build()
Action.builder()
.id("back")
.href("/customers")
.build()
Action.builder()
.id("exportAll")
.background(true)
.build()
return Form.builder()
.title("Order")
.contentItem(content)
.toolbarItem(Action.builder().id("save").validationRequired(true).build())
.toolbarItem(Action.builder().id("delete")
.confirmationRequired(true)
.confirmationTexts(ConfirmationTexts.builder()
.title("Delete order")
.confirmText("Yes, delete")
.build())
.build())
.build();
@Override
public Object handleAction(String actionId, HttpRequest httpRequest) {
return switch (actionId) {
case "save" -> {
var state = httpRequest.getComponentState(OrderState.class);
orderService.save(state);
yield null;
}
case "delete" -> {
orderService.delete(httpRequest.lastPathItem());
yield new UICommand("navigate", "/orders");
}
default -> null;
};
}