Dashboard BootstrapListener

What does the BootstrapListener in the dashboard sample do? More generally what is an extension of CubaBootstrapListener intended to be used for? I didn’t see it mentioned in the documentation.

package com.company.dashboard.web.bootstrap;

import com.haulmont.cuba.web.sys.CubaBootstrapListener;
import com.vaadin.server.BootstrapPageResponse;
import org.jsoup.nodes.Element;

public class BootstrapListener extends CubaBootstrapListener {

    public void modifyBootstrapPage(BootstrapPageResponse response) {

        Element head = response.getDocument().getElementsByTag("head").get(0);
        includeMetaViewport("width=device-width, initial-scale=0.8", response, head);

    protected void includeMetaViewport(String content, BootstrapPageResponse response, Element head) {
        Element meta = response.getDocument().createElement("meta");
        meta.attr("name", "viewport");
        meta.attr("content", content);
1 Like


CubaBootstrapListener is invoked on each initial page rendering, it allows you to include custom JavaScript libraries, CSS files, set additional tags to HTML document and so on.

It is used in the dashboard sample to tune view port settings for mobile devices using tag with viewport set to width=device-width, initial-scale=0.8.


You can read more about BootstrapListener in Vaadin documentation: https://vaadin.com/wiki/-/wiki/Main/Customizing+the+startup+page+in+an+application