Here’s an example of a simple bootstrap listener:

    Java

    The interface contains two methods, one of which is usually left empty. This is because a Vaadin application can be either stand-alone, in which case it “owns” the whole page its UI resides in, or embedded, such as a portlet, in which case it does not control the content of the page it is embedded in.

    The modifyBootstrapFragment method is called in both cases. It receives a BootstrapFragmentResponse that represents the HTML fragment that is inserted in the host page, whether the page is controlled by Vaadin or not. Hence, you only need to implement this method if you do not care about the host page, whether your application is embedded or standalone.

    Java

    But how and where should the bootstrap listeners be registered? It should be only once per session, and right in the beginning, so that they are already added when the first response is sent.

    Java