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


Java ExternalContext.getRequestContextPath方法代碼示例

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


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

示例1: redirectToServiceDetails

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public String redirectToServiceDetails() {
    logger.logDebug("entering redirectToServiceDetails");
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    String viewId = Marketplace.MARKETPLACE_ROOT + "/serviceDetails.jsf";

    try {
        viewId = extContext.getRequestContextPath()
                + viewId
                + ui.getSelectedServiceKeyQueryPart(String.valueOf(model
                        .getSelectedServiceKey()))
                + ui.getMarketplaceIdQueryPart();
        String urlLink = context.getExternalContext().encodeActionURL(
                viewId);
        JSFUtils.redirect(extContext, urlLink);
    } catch (IOException e) {
        extContext.log(
                getClass().getName() + ".redirectToServiceDetails()", e);
    } finally {
        // reset requested key;
        model.setSelectedServiceKey(null);
    }
    return null;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:25,代碼來源:ServiceDetailsCtrl.java

示例2: _resolveSourceName

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private String _resolveSourceName(
  ExternalContext  external,
  String           name)
{
  // if the path is a full URI, get it so it's from the context root
  if ( name.charAt(0) == '/' )
  {
    String contextPath = external.getRequestContextPath();
    if ( name.regionMatches( 0, contextPath, 0, contextPath.length()))
    {
      name = name.substring ( contextPath.length());
    }
    else
    {
      if (_LOG.isWarning())
        _LOG.warning("UNABLE_FLIP_ICON", new Object[]{name, contextPath});
    }
  }
  // otherwise it must be a relative path and needs to be converted to
  // a path from the context root.
  else
  {
    String rootName = external.getRequestServletPath();
    if (rootName != null)
    {
      int endIndex = rootName.lastIndexOf('/') + 1;

      name = rootName.substring(0, endIndex ) + name;
    }
  }

  return name;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:34,代碼來源:FlippedIconRequest.java

示例3: getRequestContextPath

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
 * Returns the contextPath of the ServletRequest or <code>null</code> for portlet requests
 *
 * @param ec the current external context
 * @return a String containing the request context path
 * @see ExternalContext#getRequestContextPath()
 *
 * @deprecated use ExternalContext.getRequestContextPath() as of JSF 1.2.  This method
 *             does not appropriately handle portlet environments, but the functionality
 *             is maintained to prevent needing to change the contract.
 */
@Deprecated
public static String getRequestContextPath(ExternalContext ec)
{
  if(!isPortlet(ec))
  {
    return ec.getRequestContextPath();
  }
  else
  {
   return null;
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:ExternalContextUtils.java

示例4: getRootUrl

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private String getRootUrl(ExternalContext externalContext) {
    return externalContext.getRequestContextPath();
}
 
開發者ID:atbashEE,項目名稱:atbash-octopus,代碼行數:4,代碼來源:LogoutHandler.java

示例5: getBaseSkinStyleSheetURI

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
 * Given a Skin's stylesheet name that is being parsed,
 * return an absolute base URI pointing to the
 * directory which contains the skin style sheet.  We will use this
 * base URI to ensure that URLs specified in the style sheet
 * (eg. background-image URLs) are resolved appropriately
 * (ie. not relative to the generated style sheet).
 * 
 * @param styleSheetName - The Skin's stylesheet name. E.g., "/skins/purple/purpleSkin.css"
 * @return an absolute base URI pointing to the
// directory which contains the skin style sheet. e.g., "/trinidad-context/skins/purple"
 */
public static String getBaseSkinStyleSheetURI(String styleSheetName)
{
  // The styleSheetName is actually a context-relative URI.
  // We need to strip off the file name and prepend the
  // context path.
  
  // First, get the context path.
  // Note that our options for obtaining the context path at
  // this point are somewhat limited.  We could require that
  // the caller pass this in, though this would require
  // passing this information through many layers for non-obvious
  // reasons.  Instead, we rely on the fact that we can obtain
  // this information through the FacesContext (actually,
  // through the ExternalContext), which we have access to here.
  // This is slightly ugly, since this introduces a dependency
  // from our CSS parsing code on JavaServer Faces, but until
  // we find use cases where our skinning architecture will be
  // applied in a non-Faces environment, this dependency seems
  // accpetable.
  FacesContext facesContext = FacesContext.getCurrentInstance();
  
  // We now have one use case where access to a FacesContext may
  // not be available: unit tests.  For this case, any base uri
  // will do, since we won't be requesting the style sheet via
  // a uri.
  if (facesContext == null)
  {
    return styleSheetName;
  }

  ExternalContext externalContext = facesContext.getExternalContext();
  String contextPath = externalContext.getRequestContextPath();
  assert(contextPath != null);

  int contextPathLength = contextPath.length();

  // Before we combine the context path and styleSheetName name to
  // produce the base URI, make sure that these values are
  // in the expected form
  assert(contextPathLength > 0);
  assert(contextPath.charAt(0) == '/');
  assert(contextPath.charAt(contextPathLength - 1) != '/');
  assert(styleSheetName.length() > 0);
  assert(styleSheetName.charAt(0) != '/');

  // Our internal css files are under /META-INF/adf/styles, though
  // images are accessed via <contextPath>/adf/images.  As such,
  // we also need to strip off the bonus "/META_INF" prefix from
  // the source name.  Otherwise, image requests won't be
  // resolved since /META-INF is not exposed via HTTP.
  if (styleSheetName.startsWith("META-INF/"))
    styleSheetName = styleSheetName.substring(9);

  // Find the start of the file name part of the source name - we don't
  // need this as part of the base URI
  int lastSepIndex = styleSheetName.lastIndexOf('/');
  
  if (lastSepIndex == -1)
    return contextPath;
  else
  {
    StringBuilder buffer = new StringBuilder(
                                  contextPathLength + lastSepIndex + 1);
    buffer.append(contextPath);
    buffer.append("/");
    buffer.append(styleSheetName.substring(0, lastSepIndex));
    return buffer.toString();
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:82,代碼來源:CSSUtils.java

示例6: _generateDesignTimeURL

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
 * This method returns the modified URL for design time to pick up the resources
 * from the Trinidad jar, and dynamic resources from temp cache directory.
 */
@SuppressWarnings("unchecked")
private static String _generateDesignTimeURL(
  UIXRenderingContext context,
  String baseURL
  )
{
  String designTimeURL;
  String tempCacheDirectory;
  String resourceDirectoryPath;

  Configuration configInfo = context.getConfiguration();
  ExternalContext external = context.getFacesContext().getExternalContext();

  String contextURI = external.getRequestContextPath();

  // Ignore javascripts for design time
  boolean isJavascript =
     (baseURL.indexOf((String)Configuration.JSLIBS_DIRECTORY)!=-1);

  if (!baseURL.equals(configInfo.getURI(Configuration.IMAGES_CACHE_DIRECTORY,
                                        contextURI))
      && !baseURL.equals(configInfo.getURI(Configuration.STYLES_CACHE_DIRECTORY,
                                           contextURI))
      && !isJavascript)
  {
     designTimeURL =
       (ClassLoaderUtils.getResource( _BASE_DIRECTORY + baseURL)).toString();
  }
  else
  {
    Map<String, Object> appMap = external.getApplicationMap();
    if (appMap.get("javax.servlet.context.tempdir")==null)
    {
      resourceDirectoryPath = baseURL.substring(baseURL.indexOf('/') + 1);
      tempCacheDirectory    = System.getProperty("java.io.tmpdir");

      designTimeURL = "file:" + File.separator + tempCacheDirectory
                       + resourceDirectoryPath;
    }
    else
    {
      resourceDirectoryPath = baseURL;
      tempCacheDirectory    =
        ((File)appMap.get("javax.servlet.context.tempdir")).getAbsolutePath();
      designTimeURL = tempCacheDirectory + resourceDirectoryPath;
    }
  }

  return designTimeURL;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:55,代碼來源:BaseLafUtils.java


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