當前位置: 首頁>>代碼示例>>Java>>正文


Java VaadinRequest.getPathInfo方法代碼示例

本文整理匯總了Java中com.vaadin.server.VaadinRequest.getPathInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java VaadinRequest.getPathInfo方法的具體用法?Java VaadinRequest.getPathInfo怎麽用?Java VaadinRequest.getPathInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vaadin.server.VaadinRequest的用法示例。


在下文中一共展示了VaadinRequest.getPathInfo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMainDivId

import com.vaadin.server.VaadinRequest; //導入方法依賴的package包/類
@Override
public String getMainDivId(VaadinSession session, VaadinRequest request, Class<? extends UI> uiClass) {
    String appId = request.getPathInfo();
    if (appId == null || "".equals(appId) || "/".equals(appId)) {
        appId = "ROOT";
    }
    appId = appId.replaceAll("[^a-zA-Z0-9]", "");
    // Add hashCode to the end, so that it is still (sort of)
    // predictable, but indicates that it should not be used in CSS
    // and
    // such:
    int hashCode = appId.hashCode();
    if (hashCode < 0) {
        hashCode = -hashCode;
    }
    appId = appId + "-" + hashCode;
    return appId;
}
 
開發者ID:mcollovati,項目名稱:vaadin-vertx-samples,代碼行數:19,代碼來源:VertxVaadinService.java

示例2: extractIdFromCallback

import com.vaadin.server.VaadinRequest; //導入方法依賴的package包/類
@Override
public String extractIdFromCallback(VaadinRequest request) {
	String path = request.getPathInfo();
	if (path==null) {
		return null;
	}
	String[] pathParts = path.split("/");
	int len = pathParts.length;
	if (len < 2) {
		return null;
	}
	if (!CALLBACK_ID_NAME.equals(pathParts[len-2])) {
		return null;
	}
	return pathParts[len-1];
}
 
開發者ID:ahn,項目名稱:vaadin-oauthpopup,代碼行數:17,代碼來源:OAuthCallbackInjecter.java

示例3: isUidlRequest

import com.vaadin.server.VaadinRequest; //導入方法依賴的package包/類
/**
 * Test if current request is an UIDL request
 * @return true if in UIDL request, false otherwise
 */
private boolean isUidlRequest() {
	VaadinRequest request = VaadinService.getCurrentRequest();
	
	if (request == null)
		return false;
	
	 String pathInfo = request.getPathInfo();

	 if (pathInfo == null) {
            return false;
	 }
	 
	 if (pathInfo.startsWith("/" + ApplicationConstants.UIDL_PATH)) {
            return true;
        }

        return false;
}
 
開發者ID:chelu,項目名稱:jdal,代碼行數:23,代碼來源:VaadinAccessDeniedHandler.java

示例4: getBeanNameFromRequest

import com.vaadin.server.VaadinRequest; //導入方法依賴的package包/類
/**
 * Try to match a ant url pattern in url mapping and return the UI bean name
 * @param request vaadin request
 * @return the bean name for request, null if none.
 */
protected String getBeanNameFromRequest(VaadinRequest request) {
	String beanName = null;
	String pathInfo = request.getPathInfo();
	
	if (this.pathMatcher == null)
		this.pathMatcher = new AntPathMatcher();
	
	for (String pattern : this.urlMap.keySet())  {
		if (log.isDebugEnabled())
			log.debug("Matching pattern [" + pattern + "] over path info [" + pathInfo + "]");
		
		if (this.pathMatcher.match(pattern, request.getPathInfo())) {
			beanName = this.urlMap.get(pattern);
			if (log.isDebugEnabled())
				log.debug("Matching success. Using bean name  [" + beanName + "]");
			
			break;
		}
	}
		
	if (beanName == null)
		beanName = request.getPathInfo();
	
	return beanName;
}
 
開發者ID:chelu,項目名稱:jdal,代碼行數:31,代碼來源:UrlBeanNameUiMapping.java

示例5: handleRequest

import com.vaadin.server.VaadinRequest; //導入方法依賴的package包/類
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
    String path = request.getPathInfo();

    if (StringUtils.isEmpty(path) || StringUtils.isNotEmpty(path) && !path.startsWith(VAADIN_WEBJARS_PREFIX)) {
        return false;
    }

    log.trace("WebJar resource requested: {}", path.replace(VAADIN_WEBJARS_PREFIX, ""));

    String errorMessage = checkResourcePath(path);
    if (StringUtils.isNotEmpty(errorMessage)) {
        log.warn(errorMessage);
        response.sendError(HttpServletResponse.SC_FORBIDDEN, errorMessage);
        return false;
    }

    URL resourceUrl = getStaticResourceUrl(path);

    if (resourceUrl == null) {
        resourceUrl = getClassPathResourceUrl(path);
    }

    if (resourceUrl == null) {
        String msg = String.format("Requested WebJar resource is not found: %s", path);
        response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
        log.warn(msg);
        return false;
    }

    String resourceName = getResourceName(path);
    String mimeType = servletContext.getMimeType(resourceName);
    response.setContentType(mimeType != null ? mimeType : FileTypesHelper.DEFAULT_MIME_TYPE);

    String cacheControl = "public, max-age=0, must-revalidate";
    int resourceCacheTime = getCacheTime(resourceName);
    if (resourceCacheTime > 0) {
        cacheControl = "max-age=" + String.valueOf(resourceCacheTime);
    }
    response.setHeader("Cache-Control", cacheControl);
    response.setDateHeader("Expires", System.currentTimeMillis() + (resourceCacheTime * 1000));

    InputStream inputStream = null;
    try {
        URLConnection connection = resourceUrl.openConnection();
        long lastModifiedTime = connection.getLastModified();
        // Remove milliseconds to avoid comparison problems (milliseconds
        // are not returned by the browser in the "If-Modified-Since"
        // header).
        lastModifiedTime = lastModifiedTime - lastModifiedTime % 1000;
        response.setDateHeader("Last-Modified", lastModifiedTime);

        if (browserHasNewestVersion(request, lastModifiedTime)) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return true;
        }

        inputStream = connection.getInputStream();

        copy(inputStream, response.getOutputStream());

        return true;
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:69,代碼來源:CubaWebJarsHandler.java


注:本文中的com.vaadin.server.VaadinRequest.getPathInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。