Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Add Bootstrap listeners to VaadinSession on JmixVaadinServlet initialization #287

Closed
glebfox opened this issue Feb 3, 2021 · 0 comments
Closed
Assignees
Milestone

Comments

@glebfox
Copy link
Contributor

glebfox commented Feb 3, 2021

For QA:

Add custom BootstrapListener that modifies the main page, e.g.:

import com.vaadin.server.BootstrapFragmentResponse;
import com.vaadin.server.BootstrapListener;
import com.vaadin.server.BootstrapPageResponse;
import org.jsoup.nodes.Element;
import org.springframework.stereotype.Component;

@Component(CustomBootstrapListener.NAME)
public class CustomBootstrapListener implements BootstrapListener {

    public static final String NAME = "demo_BootstrapListener";

    @Override
    public void modifyBootstrapFragment(BootstrapFragmentResponse response) {
    }

    @Override
    public void modifyBootstrapPage(BootstrapPageResponse response) {
        Element head = response.getDocument().getElementsByTag("head").get(0);

        Element meta = response.getDocument().createElement("meta");
        meta.attr("name", "viewport");
        meta.attr("content", "width=device-width, initial-scale=" + 0.8);
        head.appendChild(meta);
    }
}

Check result:

Screenshot 2021-02-09 at 11 55 53

@glebfox glebfox added this to the 0.3.0 milestone Feb 3, 2021
@glebfox glebfox self-assigned this Feb 3, 2021
@natfirst natfirst assigned lovtsovaik and unassigned natfirst Feb 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants