Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
Changing favicon dynamically
Hello,
I would like to change favicon dynamically. Following solution works from Eclipse, but doesn't work, when application is in war file:
class CheckFavicon implements Runnable {
private final static String faviconScript = "var link = document.createElement('link');\n"
+ "link.type = 'image/x-icon';\n"
+ "link.rel = 'shortcut icon';\n"
+ "link.href = './../VAADIN/themes/PSETheme/%s';\n"
+ "document.getElementsByTagName('head')[0].appendChild(link);";
@Override
public void run() {
for (Component component : tabSheet) {
if (StringUtils.contains(tabSheet.getTab(component).getStyleName(), "alert")) {
UI.getCurrent().access(() -> {
Page.getCurrent().getJavaScript().execute(String.format(faviconScript, "favicon-red.ico"));
});
return;
}
}
UI.getCurrent().access(() -> {
Page.getCurrent().getJavaScript().execute(String.format(faviconScript, "favicon.ico"));
});
}
}
Does it exist a way to change it from war file?
Last updated on
You cannot reply to this thread.