Notification
A toast-style notification that appears briefly to inform the user. Typically returned from an action handler rather than embedded statically.
Basic usage
Section titled “Basic usage”new Notification("Operation completed successfully.")Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
title | String | "" | Bold heading line |
text | String | — | Body text |
style | String | "" | Inline CSS |
cssClasses | String | "" | CSS class names |
Constructors
Section titled “Constructors”// text onlynew Notification("Saved!")
// title + textnew Notification("Success", "Record has been saved.")
// builderNotification.builder() .title("Error") .text("Could not connect to the server.") .build()Returning from an action
Section titled “Returning from an action”The most common pattern is to return a Notification from an action handler so it appears as a toast after the action completes:
@Overridepublic Object handleAction(String actionId, HttpRequest request) { if ("save".equals(actionId)) { save(formData); return new Notification("Saved!", "Your changes have been stored."); } return new State(this);}Embedded in a form
Section titled “Embedded in a form”A Notification can also be placed statically inside a Form’s header to display a persistent message:
Form.builder() .header(List.of( Notification.builder().title("Draft").text("This record has unsaved changes.").build() )) .content(formContent) .build()