Add this custom Vaadin servlet to show a different favicon (other than the Vaadin default) in your UI application –
[java]
import com.vaadin.server.*;
import com.vaadin.spring.server.SpringVaadinServlet;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
@Component("vaadinServlet")
public class CustomServlet extends SpringVaadinServlet {
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
getService().addSessionInitListener((SessionInitListener) event -> event.getSession().addBootstrapListener(new BootstrapListener() {
@Override
public void modifyBootstrapFragment(
BootstrapFragmentResponse response) {
// TODO Auto-generated method stub
}
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
response.getDocument().head().
getElementsByAttributeValue("rel", "shortcut icon").attr("href", "./images/favicon.png");
response.getDocument().head()
.getElementsByAttributeValue("rel", "icon")
.attr("href", "./images/favicon.png");
}}
));
}
}
[/java]
Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.