NotificationFacet
NotificationFacet is a facet that allows you to pre-configure a notification. Declarative definition of the notification replaces existing Notifications.create() method.
Component’s XML-name: notification.
Attributes
NotificationFacet is defined in the facets element of the screen XML descriptor and has the following attributes:
You can bind NotificationFacet to action or button. In those cases, the notification will appear when action is fires or button clicks. To aware NotificationFacet with action or button, use the following attributes:
-
onAction
<window xmlns="http://jmix.io/schema/ui/window"
caption="msg://notificationFacetScreen.caption">
<actions>
<action id="facetAction"
caption="Action subscription"/>
</actions>
<facets>
<notification id="actionNotification"
caption="Action performed"
type="TRAY"
onAction="facetAction"/>
</facets>
<layout>
</layout>
</window>
<window xmlns="http://jmix.io/schema/ui/window"
caption="msg://notificationFacetScreen.caption">
<facets>
<notification id="buttonNotification"
caption="Button clicked"
type="HUMANIZED"
onButton="facetBtn"/>
</facets>
<layout>
<button id="facetBtn"
caption="Button subscription"/>
</layout>
</window>
|
You can also make notification configured with
|
Events and Handlers
|
To generate a handler stub in Jmix Studio, select the facet in the screen descriptor XML or in the Jmix UI hierarchy panel and use the Handlers tab of the Jmix UI inspector panel. Alternatively, you can use the Generate Handler button in the top panel of the screen controller. |
CloseEvent
CloseEvent allows you to handle the closure of notification. For example:
private static final Logger log = LoggerFactory.getLogger(NotificationFacetScreen.class);
@Subscribe("actionNotification")
public void onActionNotificationClose(Notifications.CloseEvent event) {
log.info("Notification was closed");
}
Programmatic registration of the event handler: use the addCloseListener() component method.
CaptionProvider
To change the displayed caption of notification, NotificationFacet has CaptionProvider.
@Install(to = "actionNotification", subject = "captionProvider")
private String actionNotificationCaptionProvider() {
return "Changed caption";
}
Programmatic usage: call the setCaptionProvider() component method.
DescriptionProvider
To change the displayed description of notification, NotificationFacet has DescriptionProvider.
@Install(to = "actionNotification", subject = "descriptionProvider")
private String actionNotificationDescriptionProvider() {
return "Changed description";
}
Programmatic usage: call the setDescriptionProvider() component method.
All XML Attributes
|
You can view and edit attributes applicable to the facet using the Jmix UI inspector panel of the Studio’s Screen Designer. |
caption - contentMode - delay - description - htmlSanitizerEnabled - id - onAction - onButton - position - stylename - type