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


Java FacesContext.getExternalContext方法代码示例

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


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

示例1: encodeAllAsElement

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@Override
protected void encodeAllAsElement(
  FacesContext     context,
  RenderingContext rc,
  UIComponent      component,
  FacesBean        bean
  ) throws IOException
{
   // call super...
  super.encodeAllAsElement(context, rc, component, bean);

  // now evaluate the EL
  // We need to evaluate it here and store it on the sessionMap because
  // during UploadedFileProcessor.processFile() there is no FacesContext
  RequestContext requestContext = RequestContext.getCurrentInstance();
  Object maxMemory = requestContext.getUploadedFileMaxMemory();
  Object maxDiskSpace = requestContext.getUploadedFileMaxDiskSpace();
  Object tempDir = requestContext.getUploadedFileTempDir();
  ExternalContext external = context.getExternalContext();
  Map<String, Object> sessionMap = external.getSessionMap();
  sessionMap.put(UploadedFileProcessor.MAX_MEMORY_PARAM_NAME, maxMemory);
  sessionMap.put(UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME, maxDiskSpace);
  sessionMap.put(UploadedFileProcessor.TEMP_DIR_PARAM_NAME, tempDir);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:SimpleInputFileRenderer.java

示例2: getSkin

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * given the skinId, pass back the Skin.
 *
 * @param context FacesContext. If not available, pass in null.
 * @param skinId
 * @return Skin that is in this SkinFactory and has the skinId.
 * @deprecated use SkinProvider to query skins
 */
@Deprecated
@Override
public Skin getSkin(FacesContext context, String skinId)
{
  context = SkinUtils.getNonNullFacesContext(context);

  if (skinId == null)
  {
    _LOG.warning("CANNOT_GET_SKIN_WITH_NULL_SKINID");
    return null;
  }

  ExternalContext ec = context.getExternalContext();
  SkinMetadata skinMetadata = new SkinMetadata.Builder().id(skinId).build();
  return SkinProvider.getCurrentInstance(ec).getSkin(ec, skinMetadata);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:SkinFactoryImpl.java

示例3: getContentHandlerMap

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
* Returns the map of content handlers
* which hold the state of one XML tree.
* @param scopeMap
* @return
*/
 protected Map<Object, List<MenuContentHandler> > getContentHandlerMap()
 {
   FacesContext facesContext = FacesContext.getCurrentInstance();
   ExternalContext externalContext = facesContext.getExternalContext();
   Map<String, Object> scopeMap =
       externalContext.getApplicationMap();
  Object lock  = externalContext.getContext();
  
  // cannot use double checked lock here as
  // we cannot mark the reference as volatile
  // therefore any reads should happen inside
  // a synchronized block.
  synchronized (lock)
  {
    TransientHolder<Map<Object, List<MenuContentHandler> >> holder =  
      (TransientHolder<Map<Object, List<MenuContentHandler> >>) scopeMap.get(_CACHED_MODELS_KEY);
     Map<Object, List<MenuContentHandler>> contentHandlerMap = (holder != null) ? holder.getValue() : null;
     if (contentHandlerMap == null)
     {
       contentHandlerMap =
           new ConcurrentHashMap<Object, List<MenuContentHandler>>();
       scopeMap.put(_CACHED_MODELS_KEY, TransientHolder.newTransientHolder( contentHandlerMap) );
       scopeMap.put(_CACHED_MODELS_ID_CNTR_KEY,new AtomicInteger(-1));
     }
     return contentHandlerMap;
   }
   
 }
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:35,代码来源:XMLMenuModel.java

示例4: skipValidation

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public static boolean skipValidation(final FacesContext context) {
	final ExternalContext externalContext = context.getExternalContext();
	final Object validate = externalContext.getRequestMap().get(GetParamNames.VALIDATE.toString());
	if (validate != null) {
		return !(Boolean) validate;
	}
	Iterator<Entry<String, String[]>> parameterValuesIt = externalContext.getRequestParameterValuesMap()
			.entrySet().iterator();
	while (parameterValuesIt.hasNext()) {
		Entry<String, String[]> parameterValues = parameterValuesIt.next();
		final String key = parameterValues.getKey();
		Iterator<String> idPrefixIt = VALIDATION_REQUIRED_COMPONENT_ID_PREFIXES.iterator();
		while (idPrefixIt.hasNext()) {
			String idPrefix = idPrefixIt.next();
			if (key.contains(idPrefix)) {
				externalContext.getRequestMap().put(GetParamNames.VALIDATE.toString(), Boolean.TRUE);
				return false;
			}
		}
	}
	externalContext.getRequestMap().put(GetParamNames.VALIDATE.toString(), Boolean.FALSE);
	return true;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:24,代码来源:ValidatorUtil.java

示例5: shouldInterpretEmptyStringSubmittedValuesAsNull

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * Checks if the <code>validate()</code> should interpret an empty
 * submitted value should be handle as <code>NULL</code>
 *
 * @return a (cached) boolean to identify the interpretation as null
 */
public static boolean shouldInterpretEmptyStringSubmittedValuesAsNull(FacesContext context)
{
  ExternalContext ec = context.getExternalContext();
  Boolean interpretEmptyStringAsNull = (Boolean)ec.getApplicationMap().get(TRINIDAD_EMPTY_VALUES_AS_NULL_PARAM_NAME);

  // not yet cached...
  if (interpretEmptyStringAsNull == null)
  {
    // parses the web.xml to get the "javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL" value
    String param = ec.getInitParameter(JSF_SPEC_EMPTY_VALUES_AS_NULL_PARAM_NAME);

    // evaluate the context parameter
    interpretEmptyStringAsNull = "true".equalsIgnoreCase(param);

    // cache the parsed value
    ec.getApplicationMap().put(TRINIDAD_EMPTY_VALUES_AS_NULL_PARAM_NAME, interpretEmptyStringAsNull);
  }

  return interpretEmptyStringAsNull;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:UIXEditableValueTemplate.java

示例6: PartialViewContextImpl

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public PartialViewContextImpl(FacesContext context)
{
  _context = context;

  ExternalContext extContext = context.getExternalContext();

  _requestType = ReqType.FULL;

  if (_PARTIAL_AJAX.equals(extContext.getRequestHeaderMap().get(_FACES_REQUEST)))
  {
    // This request was sent with jsf.ajax.request()
    if (extContext.getRequestParameterMap().get(_TRINIDAD_PPR) != null)
      _requestType = ReqType.AJAX_LEGACY;
    else
      _requestType = ReqType.AJAX;
  }
  else if (CoreRenderKit.isLegacyPartialRequest(extContext))
  {
    _requestType = ReqType.LEGACY;
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:22,代码来源:PartialViewContextImpl.java

示例7: entrySelected

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void entrySelected() {
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext extContext = context.getExternalContext();
    LandingpageEntryModel selectedEntry = findSelectedEntry(model
            .getSelectedEntryKey());
    try {
        JSFUtils.redirect(extContext, selectedEntry.getRedirectUrl());
    } catch (Exception e) {
        extContext.log(getClass().getName() + ".startService()", e);
    } finally {
        // reset requested key;
        model.setSelectedEntryKey(null);
        model.setSelectedCategory(0);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:EnterpriseLandingpageCtrl.java

示例8: _warnedClientIdCachingConfig

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private static boolean _warnedClientIdCachingConfig(FacesContext context)
{
  ExternalContext external = context.getExternalContext();
  Map<String, Object> appMap = external.getApplicationMap();

  return Boolean.TRUE.equals(appMap.get(_WARNED_CLIENT_ID_CACHING_KEY));
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:8,代码来源:UIXComponentBase.java

示例9: _clientIdCachingConfigWarned

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private static void _clientIdCachingConfigWarned(FacesContext context)
{
  ExternalContext external = context.getExternalContext();
  Map<String, Object> appMap = external.getApplicationMap();

  appMap.put(_WARNED_CLIENT_ID_CACHING_KEY, Boolean.TRUE);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:8,代码来源:UIXComponentBase.java

示例10: shortCircuitRenderView

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public boolean shortCircuitRenderView(
  FacesContext context) throws IOException
{
  ExternalContext ec = context.getExternalContext();
  if (isPartialRequest(ec))
  {
    Map<String, Object> requestMap = ec.getRequestMap();

    UIViewRoot originalRoot = (UIViewRoot) requestMap.get(
                       TrinidadPhaseListener.INITIAL_VIEW_ROOT_KEY);
    // If we're doing a partial update, and the page has changed, switch to a
    // full page context.
    if (context.getViewRoot() != originalRoot)
    {
      ViewHandler vh = context.getApplication().getViewHandler();

      String viewId = context.getViewRoot().getViewId();
      String redirect = vh.getActionURL(context, viewId);
      String encodedRedirect = ec.encodeActionURL(redirect);
      ec.redirect(encodedRedirect);
      if (_LOG.isFine())
      {
        _LOG.fine("Page navigation to {0} happened during a PPR request " +
                  "on {1};  Apache Trinidad is forcing a redirect.",
                  new String[]{viewId, originalRoot.getViewId()});
      }

      return true;
    }
  }

  // =-=AEW We could look for PPR requests that have no
  // requested partial targets, in particular requests
  // that simply need to launch a dialog.
  return false;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:38,代码来源:CoreRenderKit.java

示例11: FacesURLEncoder

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * @todo Does this ever need to be absolute?
 */
public FacesURLEncoder(FacesContext context)
{
  _externalContext = context.getExternalContext();

  String viewId = context.getViewRoot().getViewId();
  _defaultURL =
    context.getApplication().getViewHandler().getActionURL(context, viewId);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:12,代码来源:FacesURLEncoder.java

示例12: getSkin

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
protected Skin getSkin(FacesContext context)
{
  Skin skin = null;
  ExternalContext externalContext = context.getExternalContext();
  SkinProvider skinProvider = SkinProvider.getCurrentInstance(externalContext);
  Object skinIdObj = externalContext.getRequestParameterMap().get("skinId");

  if (skinIdObj != null)
    skin = skinProvider.getSkin(externalContext, new SkinMetadata.Builder().id(skinIdObj.toString()).build());

  return skin;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:13,代码来源:TranslationsResourceLoader.java

示例13: _getInternalView

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
private InternalView _getInternalView(
  FacesContext context, 
  String       viewId)
{
  Object cached = _internalViewCache.get(viewId);
  if (cached != null)
  {
    return ((cached == _NOT_FOUND) ? null : (InternalView)cached);
  }
  
  InternalView internal = _internalViews.get(viewId);
  if (internal == null)
  {
    // If we're using suffix-mapping, then any internal viewId will
    // get affixed with ".jsp" or ".jspx";  try trimming that off
    // if present
    ExternalContext external = context.getExternalContext();
    
    // Only bother when using suffix-mapping (path info will always
    // be non-null for prefix-mapping)
    if (external.getRequestPathInfo() == null)
    {
      String suffix = external.getInitParameter("javax.faces.DEFAULT_SUFFIX");
      if (suffix == null)
        suffix = ".jspx";
      
      if (viewId.endsWith(suffix))
      {
        String viewIdWithoutSuffix = viewId.substring(
           0, viewId.length() - suffix.length());
        internal = _internalViews.get(viewIdWithoutSuffix);
      }
    }
  }
  
  _internalViewCache.put(viewId, (internal == null) ? _NOT_FOUND : internal);

  return internal;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:40,代码来源:ViewDeclarationLanguageFactoryImpl.java

示例14: listarProvaAvaliador

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
public void listarProvaAvaliador() {
	zerarLista();
	FacesContext fc = FacesContext.getCurrentInstance();
	ExternalContext ec = fc.getExternalContext();
	HttpSession session = (HttpSession) ec.getSession(false);
	Usuario usuariologado=(Usuario)session.getAttribute("usuario");
	if (parecerProvaFiltrada != null && !parecerProvaFiltrada.isEmpty()) {
		list.addAll(dao.findByNameAvaliador(parecerProvaFiltrada,usuariologado));
	} else {
		list.addAll(dao.findAllAvaliador(usuariologado));
	}
}
 
开发者ID:IsadoraScusselFarias,项目名称:ProjetoFinalInitium,代码行数:13,代码来源:ProvaBean.java

示例15: _isBeanValidationAvailable

import javax.faces.context.FacesContext; //导入方法依赖的package包/类
/**
 * This boolean indicates if Bean Validation is present.
 *
 * @return a (cached) boolean to identify if bean validation is present
 */
private static boolean _isBeanValidationAvailable(FacesContext context)
{
  ExternalContext ec = context.getExternalContext();
  Boolean couldLoadBeanValidationAPI = (Boolean) ec.getApplicationMap().get(TRINIDAD_BEAN_VALIDATION_AVAILABLE);

  // not yet cached...
  if (couldLoadBeanValidationAPI == null)
  {
    try
    {
      couldLoadBeanValidationAPI = Boolean.valueOf(ClassLoaderUtils.loadClass("javax.validation.Validation") != null);

      if (couldLoadBeanValidationAPI)
      {
        try
        {
          // Trial-error approach to check for Bean Validation impl existence.
          Validation.buildDefaultValidatorFactory().getValidator();
        }
        catch (Exception validationException)
        {
          // From section 3.5.6.2 of the spec 
          // "If the BeanValidator is used an no ValidatorFactory can be retrieved, a FacesException is raised. " 
          // Only BeanValidator needs to throw a FacesException, in this case just log the message
          // and behave as if bean validation is disabled
          _LOG.warning("VALIDATOR_FACTORY_UNAVAILABLE", validationException.getMessage());
          couldLoadBeanValidationAPI = Boolean.FALSE;
        }
      }
    }
    catch (ClassNotFoundException cnfe)
    {
      // SPEC section 3.5.6.2:
      // if a Bean Validation provider is not present, bean validation is disabled
      // TODO need a better warning (i18n) here, which has more information
      _LOG.warning("A Bean Validation provider is not present, therefore bean validation is disabled");
      couldLoadBeanValidationAPI = Boolean.FALSE;
    }

    // cache the parsed value
    ec.getApplicationMap().put(TRINIDAD_BEAN_VALIDATION_AVAILABLE, couldLoadBeanValidationAPI);
  }

  return couldLoadBeanValidationAPI;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:51,代码来源:UIXEditableValueTemplate.java


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