当前位置: 首页>>代码示例>>Java>>正文


Java BootstrapPageResponse.getDocument方法代码示例

本文整理汇总了Java中com.vaadin.server.BootstrapPageResponse.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java BootstrapPageResponse.getDocument方法的具体用法?Java BootstrapPageResponse.getDocument怎么用?Java BootstrapPageResponse.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.server.BootstrapPageResponse的用法示例。


在下文中一共展示了BootstrapPageResponse.getDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyBootstrapPage

import com.vaadin.server.BootstrapPageResponse; //导入方法依赖的package包/类
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
    Document document = response.getDocument();
    Element head = document.getElementsByTag("head").get(0);

    for (ApplicationIcon icon : applicationIcon) {
        // <link rel="apple-touch-icon" sizes="114x114"
        // href="touch-icon-iphone4.png" />
        Element iconEl = document.createElement("link");
        iconEl.attr("rel", "apple-touch-icon");
        String sizes = icon.getSizes();
        if (sizes != null) {
            iconEl.attr("sizes", sizes);
        }
        iconEl.attr("href", icon.getHref());
        head.appendChild(iconEl);
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:19,代码来源:ApplicationIcons.java

示例2: modifyBootstrapPage

import com.vaadin.server.BootstrapPageResponse; //导入方法依赖的package包/类
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {

    Document document = response.getDocument();

    Element html = document.getElementsByTag("html").get(0);
    Element head = document.getElementsByTag("head").get(0);

    DocumentType doctype = (DocumentType) html.previousSibling();
    DocumentType html5doc = new DocumentType("html", "", "", "");
    doctype.replaceWith(html5doc);

    Element element = document.createElement("meta");
    element.attr("name", "viewport");
    StringBuilder content = new StringBuilder();
    boolean open = false;
    open = addViewPortRule(content, open, "width", getViewPortWidth());
    if (!isViewPortUserScalable()) {
        open = addViewPortRule(content, open, "user-scalable", "no");
    }
    open = addViewPortRule(content, open, "initial-scale",
            getViewPortInitialScale());
    open = addViewPortRule(content, open, "maximum-scale",
            getViewPortMaximumScale());
    open = addViewPortRule(content, open, "minimum-scale",
            getViewPortMaximumScale());
    element.attr("content", content.toString());
    head.appendChild(element);

    // meta tag to disable gray tap highlights in WP8 (note, for some reason
    // these do not appear in W8, not even RT)
    // <meta name="msapplication-tap-highlight" content="no" />
    element = document.createElement("meta");
    element.attr("name", "msapplication-tap-highlight");
    element.attr("content", "no");
    head.appendChild(element);

}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:39,代码来源:ViewPortSettings.java

示例3: modifyBootstrapPage

import com.vaadin.server.BootstrapPageResponse; //导入方法依赖的package包/类
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
    Document document = response.getDocument();

    Element head = document.getElementsByTag("head").get(0);

    Element element;

    if (isWebAppCapable()) {
        element = document.createElement("meta");
        element.attr("name", "apple-mobile-web-app-capable");
        element.attr("content", "yes");
        head.appendChild(element);
    }

    if (getStatusBarStyle() != null) {
        element = document.createElement("meta");
        element.attr("name", "apple-mobile-web-app-status-bar-style");
        element.attr("content", getStatusBarStyle());
        head.appendChild(element);
    }

    if (getStartupImage() != null) {
        element = document.createElement("link");
        element.attr("rel", "apple-touch-startup-image");
        element.attr("href", getStartupImage());
        head.appendChild(element);
    }

    /*
     * Ensure window has "stable name", in case PreserveOnRefresh is used.
     * This is to fool vaadinBootstrap.js so that for example applications
     * used as ios "home screen webapps", can preserve their state among app
     * switches, like following links (with browser) and then returning back
     * to app.
     */
    if (response.getUiClass().getAnnotation(PreserveOnRefresh.class) != null) {
        element = document.createElement("script");
        element.attr("type", "text/javascript");
        element.appendText("\nwindow.name = '"
                + response.getUiClass().hashCode() + "';\n");
        head.appendChild(element);
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:45,代码来源:WebAppSettings.java

示例4: modifyBootstrapPage

import com.vaadin.server.BootstrapPageResponse; //导入方法依赖的package包/类
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
    Document document = response.getDocument();

    // Add the widgetsetUrl parameter to the bootstrap parameters.
    // This is overridden to avoid adding the naive random query
    // parameter (used by core to avoid caching of js file).

    final VaadinService service = response.getSession().getService();
    final VaadinRequest request = response.getRequest();
    final String staticFilePath = service
            .getStaticFileLocation(request);
    // VAADIN folder location
    final String vaadinDir = staticFilePath + "/VAADIN/";
    // Figure out widgetset
    final UICreateEvent event = new UICreateEvent(request,
            response.getUiClass());
    String widgetset = response.getUIProvider().getWidgetset(event);
    if (widgetset == null) {
        widgetset = request.getService()
                .getConfiguredWidgetset(request);
    }
    // Url for the widgetset
    final String widgetsetUrl = String.format(
            "%swidgetsets/%s/%s.nocache.js", vaadinDir, widgetset,
            widgetset);

    // Update the bootstrap page
    Element scriptTag = document.getElementsByTag("script").last();
    String script = scriptTag.html();
    scriptTag.html("");

    script = script.replace("});", ",\"widgetsetUrl\":\"" + widgetsetUrl
            + "\",\"offlineEnabled\":" + isOfflineModeEnabled() + "});");

    scriptTag.appendChild(new DataNode(script, scriptTag.baseUri()));

    if (isCacheManifestEnabled()) {
        // Add cache manifest attribute to html tag
        document.getElementsByTag("html").attr(
                "manifest",
                vaadinDir + "widgetsets/" + widgetset + "/"
                        + generateManifestFileName(response));
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:46,代码来源:ApplicationCacheSettings.java


注:本文中的com.vaadin.server.BootstrapPageResponse.getDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。