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


Java ExternalContext.getRequestMap方法代码示例

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


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

示例1: setupRequest

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Sets up a request for handling by the UploadedFileProcessor.  Currently this
 * copies a number of attributes from session to the request so that the
 * UploadedFileProcessor can function accordingly.
 * 
 * @param req
 */
public static void setupRequest(ExternalContext ec)
{
  //Check for Session.  If we don't have one, there is no need to set up request
  //attributes
  if(null != ec.getSession(false))
  {
    Map<String, Object> sessionMap = ec.getSessionMap();
    Map<String, Object> requestMap = ec.getRequestMap();
    
    for(String attribute:_COPIED_ATTRIBUTES)
    {
      requestMap.put(attribute, sessionMap.get(attribute));
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:23,代码来源:FileUploadUtils.java

示例2: CacheRenderKit

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public CacheRenderKit(FacesContext base)
{
  _base = base;
  ExternalContext baseExternal = base.getExternalContext();
  GlobalConfiguratorImpl config = GlobalConfiguratorImpl.getInstance();

  //This should be done only if beginRequest was not called on the configurator
  //before we retrieve the FacesContext.  If this is the case then we'll need to handle
  //cleanup on the release of the FacesContext.  Otherwise the endRequest should be
  //called by whatever did he origional beginRequest.
  if(!GlobalConfiguratorImpl.isRequestStarted(baseExternal))
  {
    Map<String, Object> requestMap = baseExternal.getRequestMap();
    requestMap.put(_CONFIG_IN_CONTEXT, Boolean.TRUE);
  }

  _external = new OverrideDispatch(config.getExternalContext(baseExternal));
  setCurrentInstance(this);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:FacesContextFactoryImpl.java

示例3: pushComponentBindingContext

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Starts a new component binding context. Typically called from tag handlers when component
 * bindings in its subtree needs to be cleared, forcing the creation of new components.
 *
 * @param context FacesContext instance
 * @see RequestContext#popComponentBindingContext
 * @see RequestContext#isInComponentBindingContext
 */
public static void pushComponentBindingContext(FacesContext context)
{
  ExternalContext ec = context.getExternalContext();
  if (null != ec)
  {
    // Use a counter on the request map to generate the IDs.
    Map<String, Object> reqMap = ec.getRequestMap();
    Integer value = (Integer)reqMap.get(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY);
    int val = 0;
    if (value == null)
    {
      val = 1;
    }
    else
    {
      val = value + 1;
    }

    reqMap.put(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY, val);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:30,代码来源:RequestContext.java

示例4: popComponentBindingContext

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Pops out of the last pushed component binding context. Component binding instances will not be
 * cleared after popping out the outermost context.
 *
 * @param context FacesContext instance
 * @see RequestContext#pushComponentBindingContext
 * @see RequestContext#isInComponentBindingContext
 */
public static void popComponentBindingContext(FacesContext context)
{
  ExternalContext ec = context.getExternalContext();
  if (null != ec)
  {
    Map<String, Object> reqMap = ec.getRequestMap();
    Integer value = (Integer)reqMap.get(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY);
    int val = 0;
    if (value == null)
    {
      _LOG.warning("POP_COMPONENT_BINDING_CONTEXT_FAILED");
    }
    else
    {
      val = value - 1;
    }

    if (val > 0)
      reqMap.put(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY, val);
    else
      reqMap.put(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY, null);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:32,代码来源:RequestContext.java

示例5: shortCircuitRenderView

import javax.faces.context.ExternalContext; //导入方法依赖的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

示例6: MultipartFormHandler

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Create a MultipartFormHandler for the given servlet request.
 */
@SuppressWarnings("unchecked")
public MultipartFormHandler(final ExternalContext externalContext) throws IOException
{
  
  this(ExternalContextUtils.getContentType(externalContext), ExternalContextUtils.getRequestInputStream(externalContext));

  // make sure that we don't try to decode this multi part request at a
  // later time; ie: if we do a forward.
  Map<String, Object> requestMap = externalContext.getRequestMap();
  requestMap.put(_HANDLED, Boolean.TRUE);
  _contentStreamSize = ExternalContextUtils.getContentLength(externalContext);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:16,代码来源:MultipartFormHandler.java

示例7: _getRequest

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
private ServletRequest _getRequest(ExternalContext ec)
{
  String uid = ec.getRequestParameterMap().get(_LAUNCH_KEY);
  if(uid != null)
  {
    /**
     * We use pageflow scope so that if something fails on the redirect, we
     * have a chance of getting cleaned up early.  This will not always happen
     * so the object may stick around for a while.
     */
    Map<String, Object> sessionMap = ec.getSessionMap();
    
    LaunchData data = (LaunchData)sessionMap.remove(_getKey(uid));
    
    //We are returning from a dialog:
    if(data != null)
    {
      Map<String, Object> requestMap = ec.getRequestMap();

      //Setting the flag to properly support isExecutingDialogReturn.
      //This is needed for isExecutingDialogReturn.
      requestMap.put(_IS_RETURNING_KEY, Boolean.TRUE);  
      
      UIViewRoot launchView = data.getLaunchView();
      if(launchView != null)
      { 
        requestMap.put(RequestContextImpl.LAUNCH_VIEW, data.getLaunchView());
      }
      
      return new ReplaceParametersRequestWrapper(
           (HttpServletRequest) ec.getRequest(), 
           data.getLaunchParam());
    }
  }
  
  return (ServletRequest)ec.getRequest();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:38,代码来源:TrinidadFilterImpl.java

示例8: getUploadedFiles

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Returns the map of uploaded files for the current request.
 */
@SuppressWarnings("unchecked")
static public UploadedFiles getUploadedFiles(ExternalContext externalContext)
{
  Map<String, Object> requestMap = externalContext.getRequestMap();
  return (UploadedFiles) requestMap.get(_UPLOADED_FILES_KEY);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:UploadedFiles.java

示例9: getSerializationWrapper

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Retrieves the current SerializationCheckingWrapper for this request
 * @param extContext
 * @param create If <code>true</code>, create the SerializationCheckingWrapper for this
 *               request if it doesn't already exist.
 * @return 
 */
public static SerializationCheckingWrapper getSerializationWrapper(
  ExternalContext extContext,
  boolean         create)
{
  // get the SerializationCheckingWrapper for this request
  Map<String, Object> requestMap = extContext.getRequestMap();
  
  Object wrapper = requestMap.get(_SERIALIZATION_WRAPPER_KEY);
  
  if (wrapper != null)
  {
    return (SerializationCheckingWrapper)wrapper;
  }
  else if (create)
  {
    // create the wrapper for this request and store it on the request so that we don't
    // recreate it
    SerializationChecker checker = SerializationChecker.getSerializationChecker(extContext,
                                                                                create);
    
    if (checker != null)
    {
      SerializationCheckingWrapper checkingWrapper = new SerializationCheckingWrapper(extContext,
                                                                                      checker);

      requestMap.put(_SERIALIZATION_WRAPPER_KEY, checkingWrapper);
   
      return checkingWrapper;
    }
  }
  
  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:41,代码来源:CheckSerializationConfigurator.java

示例10: getSerializationChecker

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Get the current SerializaionChecker for this request, potentially creating one
 * @param extContext ExternalContext to use to create the SerializationChecker
 * @param create If <code>true</code> a SerializationChecker will be created and registered
 *               for this request if one does not alreadfy exist.
 * @return
 */
public static SerializationChecker getSerializationChecker(
  ExternalContext extContext,
  boolean         create)
{
  Map<String, Object> requestMap = extContext.getRequestMap();
  
  Object checker = requestMap.get(_SERIALIZATION_CHECKER_KEY);
  
  if (checker != null)
  {
    return (SerializationChecker)checker;
  }
  else if (create)
  {
    boolean checkSession = StateUtils.checkSessionSerialization(extContext);
    boolean checkApplication = StateUtils.checkApplicationSerialization(extContext);
    boolean checkManagedBeanMutation = StateUtils.checkManagedBeanMutation(extContext);
    
    // check the possible conditions under which we would need to create a SerializationChecker
    if (checkSession || checkApplication || checkManagedBeanMutation)
    {
      boolean checkSessionAtEnd = StateUtils.checkScopesAtEndOfRequest(extContext);
        
      SerializationChecker serializationChecker = new SerializationChecker(
                                                                       extContext,
                                                                       checkSession,
                                                                       checkApplication,
                                                                       checkManagedBeanMutation,
                                                                       checkSessionAtEnd);
      
      requestMap.put(_SERIALIZATION_CHECKER_KEY, serializationChecker);
      
      return serializationChecker;
    }
  }
  
  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:46,代码来源:CheckSerializationConfigurator.java

示例11: _finishComponentReferenceInitialization

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Ensure that all DeferredComponentReferences are fully initialized before the
 * request completes
 */
private void _finishComponentReferenceInitialization(ExternalContext ec)
{
  Map<String, Object> requestMap = ec.getRequestMap();

  Collection<ComponentReference<?>> initializeList =
    (Collection<ComponentReference<?>>) requestMap.get(_FINISH_INITIALIZATION_LIST_KEY);

  if ((initializeList != null) && !initializeList.isEmpty())
  {
    RuntimeException initializationException = null;

    for (ComponentReference<?> reference: initializeList)
    {
      try
      {
        reference.ensureInitialization();
      }
      catch (RuntimeException rte)
      {
        initializationException = rte;
      }
    }

    // we've initialized everything, so we're done
    initializeList.clear();

    // rethrow the exception now that we are all done cleaning up
    if (initializationException != null)
    {
      throw initializationException;
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:38,代码来源:GlobalConfiguratorImpl.java

示例12: isInComponentBindingContext

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Returns true if we are currently within a component binding context.
 *
 * @see RequestContext#pushComponentBindingContext
 * @see RequestContext#popComponentBindingContext
 */
public static boolean isInComponentBindingContext(FacesContext context)
{
  ExternalContext ec = context.getExternalContext();
  if (null != ec)
  {
    Map<String, Object> reqMap = ec.getRequestMap();
    Integer value = (Integer)reqMap.get(_CURRENT_COMPONENT_BINDING_CONTEXT_KEY);

    if (value != null && value > 0)
      return true;
  }

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

示例13: getInstance

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Returns an instance of the RequestStateMap.  If the RequestStateMap is not present, this class will attempt to find
 * a version that was saved from {@link #saveState(ExternalContext)}.  If no state was saved, then it will create a new
 * map and return it.
 * <p/>
 * Please keep in mind that regardless of whether a map was already present on the request or not, executing this method
 * will ALWAYS clear any state which might have been saved to the session.  This is what enforces the "single restore"
 * type functionality.
 * 
 * @param ec an ExternalContext
 * @return the RequestStateMap for this ExternalContext
 */
static public RequestStateMap getInstance(ExternalContext ec)
{
  Map<String, Object> reqMap = ec.getRequestMap();
  RequestStateMap map = (RequestStateMap)reqMap.get(_STATE_MAP);
  
  //For now, always check this on a render so it can be removed from the session.
  //This can be optimized to only save the state when request attributes are NOT preserved
  if(!ExternalContextUtils.isRequestFromClient(ec))
  {
    String uuid = ec.getRequestParameterMap().get(_STATE_MAP);
    if(uuid!= null)
    {
       RequestStateMap myMap= (RequestStateMap)ec.getSessionMap().remove(_STATE_MAP+"."+uuid);
       if(map == null)
       {
         map = myMap;
         reqMap.put(_STATE_MAP, map);
       }
       else
       {
         //TODO: put optimization code here
       }
    }
  }
  
  if(map == null)
  {
    map = new RequestStateMap();
    reqMap.put(_STATE_MAP, map);
  }
  
  return map;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:46,代码来源:RequestStateMap.java

示例14: _restoreSerializedView

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
/**
 * Restore the serialized view from the incoming request.
 * @todo ensure that the caching never gets confused by two
 *       different views being reconstituted in the same request?
 */
@SuppressWarnings("unchecked")
private Object[] _restoreSerializedView(
   FacesContext context)
{
  ExternalContext external = context.getExternalContext();
  
  Map<String, Object> requestMap = external.getRequestMap();

  Object[] view = (Object[]) requestMap.get(_CACHED_SERIALIZED_VIEW);
  if (view == null)
  {
    String stateString = _getStateString(external);
    String tokenString = _tokenStringFromStateString(stateString);
 
    if (tokenString != null)
    {
      view = new Object[]{StateUtils.reconstruct(tokenString, context.getExternalContext()), null};
    }
    // Nope, let's look for a regular state field
    else
    {
      if (stateString != null)
      {
        view = (Object[]) StateUtils.reconstruct(stateString, context.getExternalContext());
        /*
        StringReader sr = new StringReader(stateString);
        BufferedReader br = new BufferedReader(sr);
        Base64InputStream b64_in = new Base64InputStream(br);


        try
        {
          ObjectInputStream ois;
          ois = new ObjectInputStreamResolveClass( new GZIPInputStream( b64_in, _BUFFER_SIZE ));

          Object structure = ois.readObject();
          Object state = ois.readObject();
          ois.close();
          view = new Object[]{structure, state};
        }
        catch (OptionalDataException ode)
        {
          _LOG.severe(ode);
        }
        catch (ClassNotFoundException cnfe)
        {
          _LOG.severe(cnfe);
        }
        catch (IOException ioe)
        {
          _LOG.severe(ioe);
        }
        */
      }
    }

    if (view != null)
      requestMap.put(_CACHED_SERIALIZED_VIEW, view);
  }

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

示例15: _handleDialogReturn

import javax.faces.context.ExternalContext; //导入方法依赖的package包/类
private void _handleDialogReturn(ExternalContext ec)
  throws IOException
{
  Map<String, Object> reqMap = ec.getRequestMap();
  
  if(Boolean.TRUE.equals(reqMap.get(DialogServiceImpl.DIALOG_RETURN)))
  {
    /**
     * We use pageflow scope so that if something fails on the redirect, we
     * have a chance of getting cleaned up early.  This will not always happen
     * so the object may stick around for a while.
     */
    Map<String, Object> sessionMap = ec.getSessionMap();
    String uid = UUID.randomUUID().toString();
    LaunchData data = new LaunchData((UIViewRoot)reqMap.get(RequestContextImpl.LAUNCH_VIEW), (Map<String, String[]>) reqMap.get(RequestContextImpl.LAUNCH_PARAMETERS));
    sessionMap.put(_getKey(uid), data);
    
    //Construct URL
    //TODO: sobryan I believe some of this can be added to the RequestContextUtils to allow
    //      this url to be constructed for both portlet and servlet environments.  We'll want to research.
    HttpServletRequest req = (HttpServletRequest) ec.getRequest();
    StringBuffer url = req.getRequestURL().append("?");
    String queryStr = req.getQueryString();
    if((queryStr != null) && (queryStr.trim().length() >0))
    {
      url.append(queryStr)
         .append("&");
    }
    
    url.append(_LAUNCH_KEY)
       .append("=")
       .append(uid);

    //Extensions to Trinidad may have alternatve means of handling PPR.  This
    //flag allows those extensions to for the <redirect> AJAX message to be returned.
    if (RequestContext.getCurrentInstance().isPartialRequest(_PSEUDO_FACES_CONTEXT.get()) || 
        Boolean.TRUE.equals(RequestStateMap.getInstance(ec).get(_FORCE_PPR_DIALOG_RETURN)))
    {
      //Special handling for XmlHttpRequest.  Would be cool to handle this much cleaner.
      HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
      XmlHttpConfigurator.sendXmlRedirect(resp.getWriter(), url.toString());
    }
    else
    {
      ec.redirect(url.toString());
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:49,代码来源:TrinidadFilterImpl.java


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