本文整理匯總了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));
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}