|
Re: Rich content in desktop notifications [message #1806557 is a reply to message #1806461] |
Fri, 10 May 2019 10:59 |
|
Hi Krzysztof
Yes, when you take a look at the JavaScript source-code in PopupBlockerHandler#showNotification, you'll see that a "variant" of DesktopNotification.js is created instead of the regular Notification:
notification = scout.create('DesktopNotification:PopupBlocker', {
parent: desktop,
linkUrl: linkUrl,
preserveOpener: this.preserveOpener
});
This instantiates the class PopupBlockerDesktopNotification.js, where the _render function creates the HTML you mentioned in your post.
In a Scout Java application you could use a @ModelVariant to mark a specific Notification class, like this:
@ModelVariant("Special")
class SpecialDesktopNotification extends DesktopNotification {
public SpecialDesktopNotification(IStatus status, long duration, boolean closable) {
super(status, duration, closable);
}
}
And add the notification like this:
DesktopNotification notification = new SpecialDesktopNotification(status, duration, closeable);
ClientSession.get().getDesktop().addNotification(notification);
In your *.ui.html project you need to add a JavaScript class "SpecialDesktopNotification.js" that extends DesktopNotification.js and register it in your module.js. Scout finds and instantiates this class by name-magic. In that class you can override the _render or _renderMessage function and implement whatever you need. A very simple approach could override _renderMessage and simply add the message from the status object as HTML, without encoding HTML as DesktopNotification.js does. Example:
scout.SpecialDesktopNotification.prototype._renderMessage = function() {
var html = scout.nvl(this.status.message, '');
this.$messageText.html(html);
};
André
Eclipse Scout Homepage | Documentation | GitHub
|
|
|
|
Re: Rich content in desktop notifications [message #1806568 is a reply to message #1806563] |
Fri, 10 May 2019 12:28 |
|
You're welcome.
Currently there's no specific plan to enhance the DesktopNotification. But I like the idea of making the notification more flexible, and while I was writing the post above, I thought it would be a good idea to add at least a "htmlEnabled" property. Some other widgets, like LabelField.js, already have that property, which allows to provide HTML content instead of plain text.
I'll add this (and your proposal about icon support) to our backlog.
Eclipse Scout Homepage | Documentation | GitHub
|
|
|
|
Re: Rich content in desktop notifications [message #1835339 is a reply to message #1835257] |
Tue, 01 December 2020 07:58 |
|
Hi Krzysztof
You can pass a special "app link handler" to the constructor of your DesktopNotification instance. Something like this:
IStatus status = new Status(HTML.span("Click me").appLink("myRef").toHtml(), IStatus.INFO);
IDesktopNotification notification = new DesktopNotification(status, IDesktopNotification.INFINITE_DURATION, true, true, ref -> MessageBoxes.createOk().withBody("You clicked this link: " + ref).show());
desktop.addNotification(notification);
Regards,
Beat
|
|
|
Powered by
FUDForum. Page generated in 0.03100 seconds