List of usage examples for com.vaadin.server BootstrapPageResponse getDocument
public Document getDocument()
From source file:com.esofthead.mycollab.vaadin.MyCollabBootstrapListener.java
License:Open Source License
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { response.getDocument().head().append("<meta http-equiv=\"pragma\" content=\"no-cache\">"); response.getDocument().head().append("<meta http-equiv=\"cache-control\" content=\"no-cache\">"); response.getDocument().head().append("<meta http-equiv=\"cache-control\" content=\"max-age=0\">"); response.getDocument().head().append("<meta http-equiv=\"expires\" content=\"-1\">"); response.getDocument().head().append("<meta name=\"robots\" content=\"nofollow\" />"); DeploymentMode deploymentMode = SiteConfiguration.getDeploymentMode(); if (deploymentMode == DeploymentMode.site) { response.getDocument().head().append( "<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js\"></script>"); response.getDocument().head().append( "<script type=\"text/javascript\" src=\"https://s3.amazonaws.com/mycollab_assets/assets/js/stickytooltip.js\"></script>"); } else {/*from w w w . j av a 2 s .c o m*/ response.getDocument().head() .append("<script type=\"text/javascript\" src=\"/assets/js/jquery-1.10.2.min.js\"></script>"); response.getDocument().head() .append("<script type=\"text/javascript\" src=\"/assets/js/stickytooltip.js\"></script>"); } }
From source file:com.haulmont.cuba.web.sys.CubaBootstrapListener.java
License:Apache License
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { Element head = response.getDocument().getElementsByTag("head").get(0); includeScript(getWebJarResource("jquery.min.js"), response, head); int customDeviceWidthForViewport = webConfig.getCustomDeviceWidthForViewport(); if (customDeviceWidthForViewport > 0) { includeMetaViewport(//from ww w. ja v a 2 s. c o m "width=" + customDeviceWidthForViewport + ", initial-scale=" + webConfig.getPageInitialScale(), response, head); } else if (webConfig.getUseDeviceWidthForViewport()) { includeMetaViewport("width=device-width" + ", initial-scale=" + webConfig.getPageInitialScale(), response, head); } }
From source file:com.haulmont.cuba.web.sys.CubaBootstrapListener.java
License:Apache License
protected void includeScript(String src, BootstrapPageResponse response, Element head) { Element script = response.getDocument().createElement("script"); script.attr("src", src); head.appendChild(script);//w w w. j a v a2 s.c o m }
From source file:com.haulmont.cuba.web.sys.CubaBootstrapListener.java
License:Apache License
protected void includeMetaViewport(String content, BootstrapPageResponse response, Element head) { Element meta = response.getDocument().createElement("meta"); meta.attr("name", "viewport"); meta.attr("content", content); head.appendChild(meta);/*from www.java2 s. c o m*/ }
From source file:com.mycollab.vaadin.MyCollabBootstrapListener.java
License:Open Source License
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { VaadinRequest request = response.getRequest(); String domain = Utils.getSubDomain(request); BillingAccountService billingService = AppContextUtil.getSpringBean(BillingAccountService.class); BillingAccount account = billingService.getAccountByDomain(domain); if (account != null) { String favIconPath = StorageFactory.getFavIconPath(account.getId(), account.getFaviconpath()); response.getDocument().head().getElementsByAttributeValue("rel", "shortcut icon").attr("href", favIconPath);/*from w w w . j av a 2 s . co m*/ response.getDocument().head().getElementsByAttributeValue("rel", "icon").attr("href", favIconPath); } response.getDocument().head().append("<meta name=\"robots\" content=\"nofollow\" />"); if (!MOBILE_APP.equals(response.getUiClass().getName()) || !Utils.isTablet(request)) { response.getDocument().head() .append(String.format( "<script type=\"text/javascript\" src=\"%sjs/jquery-2.1.4.min.js\"></script>", SiteConfiguration.getCdnUrl())); response.getDocument().head() .append(String.format( "<script type=\"text/javascript\" src=\"%sjs/stickytooltip-1.0.2.js?v=%s\"></script>", SiteConfiguration.getCdnUrl(), Version.getVersion())); Element div1 = response.getDocument().body().appendElement("div"); div1.attr("id", "div1" + TOOLTIP_ID); div1.attr("class", "stickytooltip"); Element div12 = div1.appendElement("div"); div12.attr("style", "padding:5px"); Element div13 = div12.appendElement("div"); div13.attr("id", "div13" + TOOLTIP_ID); div13.attr("class", "atip"); div13.attr("style", "width:550px"); Element div14 = div13.appendElement("div"); div14.attr("id", "div14" + TOOLTIP_ID); } }
From source file:fr.amapj.view.engine.ui.ValoThemeSessionInitListener.java
License:Open Source License
@Override public void sessionInit(final SessionInitEvent event) throws ServiceException { event.getService().setSystemMessagesProvider(new SystemMessagesProvider() { @Override/*from w w w . j a v a 2s. c o m*/ public SystemMessages getSystemMessages(final SystemMessagesInfo systemMessagesInfo) { CustomizedSystemMessages csm = new CustomizedSystemMessages(); csm.setSessionExpiredNotificationEnabled(false); return csm; } }); event.getSession().addBootstrapListener(new BootstrapListener() { @Override public void modifyBootstrapPage(final BootstrapPageResponse response) { final Element head = response.getDocument().head(); head.appendElement("meta").attr("name", "viewport").attr("content", "width=device-width, initial-scale=1"); head.appendElement("meta").attr("name", "apple-mobile-web-app-capable").attr("content", "yes"); head.appendElement("meta").attr("name", "apple-mobile-web-app-status-bar-style").attr("content", "black"); } @Override public void modifyBootstrapFragment(final BootstrapFragmentResponse response) { // TODO Auto-generated method stub } }); }
From source file:info.magnolia.ui.admincentral.AdmincentralVaadinServlet.java
License:Open Source License
@Override protected void servletInitialized() throws ServletException { super.servletInitialized(); getService().addSessionInitListener(new SessionInitListener() { @Override/*from w w w . ja v a 2s. c o m*/ public void sessionInit(SessionInitEvent event) { event.getSession().addBootstrapListener(new BootstrapListener() { @Override public void modifyBootstrapPage(BootstrapPageResponse response) { response.getDocument().head().append( "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />"); } @Override public void modifyBootstrapFragment(BootstrapFragmentResponse response) { } }); // Set up and configure UIProvider for the admincentral if (admincentralUiProvider != null) { event.getSession().addUIProvider(admincentralUiProvider); } else { log.error("Could not inject AdmincentralUIProvider."); } } }); }
From source file:org.jumpmind.metl.ui.init.AppSessionInitListener.java
License:Open Source License
@Override public void sessionInit(final SessionInitEvent event) throws ServiceException { event.getService().setSystemMessagesProvider(new SystemMessagesProvider() { private static final long serialVersionUID = 1L; @Override// w w w. j av a 2s . c o m public SystemMessages getSystemMessages(final SystemMessagesInfo systemMessagesInfo) { CustomizedSystemMessages csm = new CustomizedSystemMessages(); csm.setSessionExpiredNotificationEnabled(false); return csm; } }); event.getSession().addBootstrapListener(new BootstrapListener() { private static final long serialVersionUID = 1L; @Override public void modifyBootstrapPage(final BootstrapPageResponse response) { final Element head = response.getDocument().head(); head.appendElement("meta").attr("name", "viewport").attr("content", "width=device-width, initial-scale=1"); head.appendElement("meta").attr("name", "apple-mobile-web-app-capable").attr("content", "yes"); head.appendElement("meta").attr("name", "apple-mobile-web-app-status-bar-style").attr("content", "black"); } @Override public void modifyBootstrapFragment(final BootstrapFragmentResponse response) { // TODO Auto-generated method stub } }); }
From source file:org.vaadin.alump.vibrate.demo.VibrateSettings.java
License:Apache License
@Override public void modifyBootstrapPage(BootstrapPageResponse response) { Document doc = response.getDocument(); Element head = doc.getElementsByTag("head").get(0); // Inject viewport meta tag Element element = doc.createElement("meta"); element.attr("name", "viewport"); element.attr("content", "width=320, user-scalable=no"); head.appendChild(element);/*from w w w . j av a 2s. c o m*/ }
From source file:org.vaadin.volga.SeoBootstrapListener.java
private void addHeaders(String path, BootstrapPageResponse response, VolgaDetails details) { Class<? extends UI> uiClass = response.getUiClass(); // Generic//w w w. jav a 2s. c o m meta(response, "description", details.getSeoDescription()); // For Twitter meta(response, "twitter:card", "summary"); meta(response, "twitter:site", path + details.getSeoUrl()); meta(response, "twitter:title", details.getSeoTitle()); meta(response, "twitter:description", details.getSeoDescription()); meta(response, "twitter:image", details.getSeoImage()); // For Facebook Element html = response.getDocument().getElementsByTag("html").get(0); html.attr("prefix", "og: http://ogp.me/ns# article: http://ogp.me/ns/article#"); meta(response, "og:type", "website"); meta(response, "og:url", path + details.getSeoUrl()); meta(response, "og:title", details.getSeoTitle()); meta(response, "og:description", details.getSeoDescription()); meta(response, "og:image", details.getSeoImage()); }