Hello,
Is there any possibility to delay (keep) WARNING notification (with let say 5 seconds) regardless click action?
Best Regards,
-n
Hello,
Is there any possibility to delay (keep) WARNING notification (with let say 5 seconds) regardless click action?
Best Regards,
-n
Hi,
NotificationBuilder
has convenient method withHideDelayMs()
, e.g.:
notifications.create()
.withCaption("<i>Warning notification</i>")
.withType(NotificationType.WARNING)
.withContentMode(ContentMode.HTML)
.withHideDelayMs(5000)
.show();
Gleb
Hi Gleb,
I saw this method. Indeed the notification stays 5 seconds.
Nevertheless my question was to stay 5 seconds regardless (mouse) click.
If I click on it disappear right away. I want to freeze 5 sec.
Regards,
-n
By default Warning and Error have modality curtain by clicking on which notification hides.
Unfortunately, there is no easy way to either remove modality curtain only for Warning or ignore clicks on it. The easy way is to hide modality curtain for all type of notifications, using styles:
.c-notification-modalitycurtain {
display: none;
}
Gleb
I put it under @mixin in hover-ext.scss but unfortunately doesn’t work. Only it changed from middle to top and from yellow to blue.
notifications.create().withCaption("<i>Warning notification</i>").withType(Notifications.NotificationType.WARNING)
.withContentMode(ContentMode.HTML).withStyleName("c-notification-modalitycurtain").withHideDelayMs(5000).show();
-n
Yes.The click is still active.
I need something that blocks the app 5 seconds regardless click.
Could you please attach a demo project?
Difficult…but I can share the result of the style:
This happens immediately after Login (loginButton.addClickListener - under onInit).
The style above perfectly works for me. If the same isn’t applicable for you, I need something to investigate the problem.
Below the code:
public class ExtAppLoginWindow extends AppLoginWindow {
@Subscribe
private void onInit(InitEvent event) {
loginButton.addClickListener(e ->{
if (condition) {
notifications.create().withCaption("<i>Warning notification</i>").withType(Notifications.NotificationType.WARNING)
.withContentMode(ContentMode.HTML).withStyleName("c-notification-modalitycurtain").withHideDelayMs(5000).show();
}
});
}
}
and style
@mixin com_crm-hover-ext {
.c-notification-modalitycurtain {
display: none;
}
}
You don’t need to set this stylename to notification, so remove the following:
.withStyleName("c-notification-modalitycurtain")
Unfortunately has no effect.
Maybe you think a mechanism to suspend the use of application n second.
Could be useful.
Provided solution perfectly works for me, so I’d greatly appreciate if you manage to create a sample project demonstrating the issue.
Prevent an application from responding is extremely bad practice.
Hi
You can implement a Notification Timer inside the init method of the main Window. You can set this timer to run after a specified amount of Time.
Timer notificationTimer = componentsFactory.createTimer();
addTimer(notificationTimer);
notificationTimer.setDelay(5000);
notificationTimer.setRepeating(true);
notificationTimer.addActionListener(timer -> {
//Execution your Code here!
}
});
notificationTimer.start();
Notice that there is:
setDelay(5000) - specify the amount of time in seconds
setRepeating(true) - states that the function will be executed after every specified seconds, set false if you don’t require that.
Hi Indileni,
I’m not used Timer until now so maybe I made a mistake.
However I tried this (but I don’t think it s quite ok to use a listener inside to another one):
loginButton.addClickListener(e ->{
if(condition){
Timer notificationTimer = componentsFactory.createTimer();
addTimer(notificationTimer);
notificationTimer.setDelay(5000);
notificationTimer.setRepeating(true);
notificationTimer.addActionListener(timer -> {
notifications.create().withCaption("<i>Warning notification</i>").withType(Notifications.NotificationType.WARNING)
.withContentMode(ContentMode.HTML).withHideDelayMs(5000).show();
});
notificationTimer.start();
});
but unfortunately the code skip notificationTimer.addActionListener
do not enter inside the body so the notification is not executed.
Regards,
-n
}
Ok but at least to keep an warning on the screen how much I want without the possibility to close it.
Unfortunately
.c-notification-modalitycurtain{
display: none;
}
in my case does nothing.
Solved:used public class ExtAppMainWindow extends AppMainWindow