当前位置: 首页>>代码示例>>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;未经允许,请勿转载。