How to set a own favicon if the theme was set by UI.setTheme(...)

Hi,

I want to set a own favicon. To do that I have put my favicon.ico into my theme directory. If I set the theme by sepcifying @Theme(“mytheme”) this works. Also the right favicon is set.

But if I set the theme by calling UI.setTheme(“mytheme”) the default Vaadin favicon is displayed.

//@Theme("mytheme")  <--- this works
@PreserveOnRefresh
@Push
public class DocFlowUI extends UI {
  @Override
  public void init(VaadinRequest request) {
    setTheme("docFlow");
    ...
  }

  ...
}

The generated HTML looks like:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=11;chrome=1" />
    <style type="text/css">html, body {height:100%;margin:0;}</style>
    <link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./VAADIN/themes/reindeer/favicon.ico" />
    <link rel="icon" type="image/vnd.microsoft.icon" href="./VAADIN/themes/reindeer/favicon.ico" />
  </head>
  ...
</html>

But what I had expected is that the favicon will be taken from my theme: “./VAADIN/themes/mytheme/favicon.ico” …

How can I set my own favicon if I set the theme by calling UI.setTheme(…)?

Thanks,
Steffen



There should theoretically be no difference between the methods when it comes to favicons
In your coding
you wrote @Theme(“mytheme”) but in setTheme you have “docFlow”. Is this just a copy-paste error or might this be the problem.

In your coding you wrote @Theme(“mytheme”) but in setTheme you have “docFlow”. Is this just a copy-paste error or might this be the problem.

Yes. That’s a copy&paste error (I cannot edit and change the original post because the submit button is not working …)

Ok. I have now a simple test project (for eclipse luna) attached. In the test project I have add a theme “mytheme”. The theme has a own favicon (a red box). If I specify the theme with @Theme in the VaddintestUI it works. If I specify the theme with setTheme(“mytheme”) it doesnt work.

I have also figured out that the firefox is very strange if a favicon was changed. Anywhere the firefox will have (may be) a old favicon in the cache. Also clearing the cache of Firefox and restart jboss will not help (not sure why …). But with chrome and opera (IE not testet) I can reproduce this behaviour.

Please note also that I have removed all jar’s from WEB-INF/lib/ because otherwise the attached file will be too big …

Is this a bug or is anything wrong in my test project?
17410.gz (500 KB)

I have this reported now as a bug: http://dev.vaadin.com/ticket/15481