-
Notifications
You must be signed in to change notification settings - Fork 5
/
MyVaadinUI.java
67 lines (54 loc) · 2.1 KB
/
MyVaadinUI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package org.vaadin.inki.qrvaadin;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import org.jsoup.nodes.Element;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.BootstrapFragmentResponse;
import com.vaadin.server.BootstrapListener;
import com.vaadin.server.BootstrapPageResponse;
import com.vaadin.server.ServiceException;
import com.vaadin.server.SessionInitEvent;
import com.vaadin.server.SessionInitListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@Theme("valo")
@SuppressWarnings("serial")
public class MyVaadinUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "org.vaadin.inki.qrvaadin.AppWidgetSet")
public static class Servlet extends VaadinServlet implements
SessionInitListener, BootstrapListener {
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
getService().addSessionInitListener(this);
}
@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
event.getSession().addBootstrapListener(this);
}
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
Element head = response.getDocument().getElementsByTag("head").get(0);
// add platform.js for getting Polymer project
Element platform = response.getDocument().createElement("script");
platform.attr("src", "VAADIN/platform/platform.js");
head.appendChild(platform);
}
@Override
public void modifyBootstrapFragment(BootstrapFragmentResponse response) {}
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
layout.addComponent(new Label("QR code just for you"));
layout.addComponent(new QRContactComponent("Luke", "Skywalker",
"luke@rebels.com", "+3589285739"));
}
}