Skip navigation links
org.apache.myfaces.trinidad.util
Class RequestStateMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,Object>
org.apache.myfaces.trinidad.util.RequestStateMap
- All Implemented Interfaces:
- Serializable, Cloneable, Map<String,Object>
-
@ExcludeFromManagedRequestScope
public class RequestStateMap
- extends HashMap<String,Object>
This object provides a map that is primarily used to enforce a consistent contract for "state" information in both a portal environment and a servlet environment. In a portal environment, request-scope attributes are not necessarily "saved" between processAction and render. According to the JSF Portlet Bridge Spec, a request-scope attribute may hang around from a single processAction to multiple render requests unless it is excluded. Of course, excluding the object from the managed request scope will suffer from the problem of the request scope going away BETWEEN action and render. <p/> This class will save an attribute in a processAction portion of the request, will preserve it on the session, and will read it on the first render following the action. This allows attributes to be reliably exchanged from action to render without having to worry about subsequent renders inheriting the same state. This is useful for storing things like "ppr" data and such when a subsequent render may be expected to render the entire page. <p/> In a servlet environment, this class is the same as the request scope.
- See Also:
- Serialized Form
| Method Summary |
static RequestStateMap |
getInstance(javax.faces.context.ExternalContext ec)
Returns an instance of the RequestStateMap. |
static RequestStateMap |
getInstance(javax.servlet.ServletRequest req)
Returns an instance of the RequestStateMap. |
void |
saveState(javax.faces.context.ExternalContext ec)
Saves the current state to the session. |
| Methods inherited from class java.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
getInstance
public static RequestStateMap getInstance(javax.servlet.ServletRequest req)
- Returns an instance of the RequestStateMap. If one is not already present on the request, it will create a new one. This version of the getInstance DOES NOT attempt to restore the map from the session because such an action is only valid in a PortletEnvironment which should not have a ServletRequest. This method is provided for the convenience of getting access to the class from the filter.
-
- Parameters:
req - a servletRequest
- Returns:
- the RequestStateMap for this servletRequest
getInstance
public static RequestStateMap getInstance(javax.faces.context.ExternalContext ec)
- Returns an instance of the RequestStateMap. If the RequestStateMap is not present, this class will attempt to find a version that was saved from
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.
-
- Parameters:
ec - an ExternalContext
- Returns:
- the RequestStateMap for this ExternalContext
saveState
public void saveState(javax.faces.context.ExternalContext ec)
- Saves the current state to the session. Running this is only manditory if you need to preserve a request across the natural request boundry in a portlet environment. Executing this function outside of a portlet environment will not alter operation of his class.
-
- Parameters:
ec - the ExternalContext to save the stateMap to.
Skip navigation links
Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.