| Method from org.apache.myfaces.trinidadinternal.application.StateManagerImpl Detail: |
public static void clearReuseRequestTokenForResponse(ExternalContext ec) {
ec.getRequestMap().remove(_REUSE_REQUEST_TOKEN_FOR_RESPONSE_KEY);
}
Clears the flag indicating that the old request token should be used for the response. |
protected Object getComponentStateToSave(FacesContext context) {
throw new UnsupportedOperationException();
}
|
public static String getStateToken(FacesContext context) {
return (String) context.getExternalContext().getRequestMap().get(
_REQUEST_STATE_TOKEN_KEY);
}
|
protected Object getTreeStructureToSave(FacesContext context) {
throw new UnsupportedOperationException();
}
|
protected StateManager getWrapped() {
return _delegate;
}
|
public boolean isSavingStateInClient(FacesContext context) {
return _delegate.isSavingStateInClient(context);
}
|
public static void pinStateToRequest(FacesContext context,
String stateToken) {
context.getExternalContext().getRequestMap().put(
_PINNED_STATE_TOKEN_KEY, stateToken);
}
Requests that an old state token be "pinned" to the state of
the current request. This means that the view state corresponding
to the token will not be released before the state for this request
is released. |
protected void restoreComponentState(FacesContext context,
UIViewRoot viewRoot,
String renderKitId) {
throw new UnsupportedOperationException();
}
|
public static UIComponent restoreComponentTree(FacesContext context,
Object savedState) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
if (savedState == null)
throw new NullPointerException();
if (!(savedState instanceof PageState))
throw new IllegalArgumentException(_LOG.getMessage(
"INVALID_SAVED_STATE_OBJECT"));
PageState viewState = (PageState) savedState;
Object structure = viewState.getStructure();
Object state = viewState.getState();
UIComponent component =
((Structure) structure).createComponent();
if (state != null)
component.processRestoreState(context, state);
return component;
}
Take an object created by saveComponentTree()
and instantiate it as a UIComponent. |
protected UIViewRoot restoreTreeStructure(FacesContext context,
String viewId,
String renderKitId) {
throw new UnsupportedOperationException();
}
|
public UIViewRoot restoreView(FacesContext context,
String viewId,
String renderKitId) {
if (!isSavingStateInClient(context))
return _delegate.restoreView(context, viewId, renderKitId);
final Object structure;
final Object state;
boolean recalculateLocale = false;
ResponseStateManager rsm = _getResponseStateManager(context, renderKitId);
if (_saveAsToken(context))
{
Object token = rsm.getTreeStructureToRestore(context, viewId);
if (token == null)
{
_LOG.finest("No token in the request for view \"{0}\"; " +
"probably a first view.", viewId);
return null;
}
assert(token instanceof String);
_LOG.finer("Restoring saved view state for token {0}", token);
PageState viewState;
// Load from the application cache
if (_APPLICATION_CACHE_TOKEN.equals(token))
{
Map< String, Object > cache = _getApplicationViewCache(context);
Map< String, Object > perSessionCache =
_getPerSessionApplicationViewCache(context);
// Synchronize on the application-level cache.
// =-=AEW This may produce excessive contention
synchronized (cache)
{
// Look first in the per-session cache
viewState = (PageState) perSessionCache.get(viewId);
if (viewState == null)
{
// Nope, it's not there. Look in the application cache
viewState = (PageState) cache.get(viewId);
// And if we find it there, then push it back into
// the per-session cache (it may have expired)
if (viewState != null)
perSessionCache.put(viewId, viewState);
}
// If the view was found in the application cache then we
// know it would be unsafe to use its locale for this session.
// Same conclusion, however, even if found in the per-session
// cache, since the latter is just a mirror of the former.
recalculateLocale = true;
}
}
else
{
Map< String, Object > stateMap = new SubKeyMap(
context.getExternalContext().getSessionMap(),
_VIEW_CACHE_KEY + ".");
viewState = (PageState) stateMap.get(token);
if (viewState != null)
_updateRequestTokenForResponse(context, (String) token);
// Make sure that if the view state is present, the cache still
// has the token, and vice versa
// NOTE: it's very important that we call through to the
// token cache here, not just inside the assert. If we don't,
// then we don't actually access the token, so it doesn't
// get bumped up to the front in the LRU Cache!
boolean isAvailable =
_getViewCache(context).isAvailable((String) token);
assert ((viewState != null) == isAvailable);
}
if (viewState == null)
{
_LOG.severe("CANNOT_FIND_SAVED_VIEW_STATE", token);
return null;
}
_LOG.fine("Successfully found view state for token {0}", token);
UIViewRoot root = viewState.popRoot(context); // bug 4712492
if (root != null)
{
_LOG.finer("UIViewRoot for token {0} already exists. Bypassing restoreState", token);
return root;
}
structure = viewState.getStructure();
state = viewState.getState();
}
else
{
structure = rsm.getTreeStructureToRestore(context, viewId);
state = rsm.getComponentStateToRestore(context);
}
if (structure == null)
{
UIViewRoot root = context.getViewRoot();
if (root == null && _needStructure(context))
{
_LOG.severe("NO_STRUCTURE_ROOT_AVAILABLE");
return null;
}
if (state != null)
root.processRestoreState(context, state);
return root;
}
else
{
if (!(structure instanceof Structure))
{
_LOG.severe("NO_STRUCTURE_AVAILABLE");
return null;
}
// OK, we've structure and state; let's see what we can do!
try
{
UIViewRoot root = (UIViewRoot)
((Structure) structure).createComponent();
if (state != null)
root.processRestoreState(context, state);
if (recalculateLocale)
{
// Ensure that locale gets re-calculated when next fetched.
root.setLocale((Locale) null);
}
_LOG.finer("Restored state for view \"{0}\"", viewId);
return root;
}
catch (ClassNotFoundException cnfe)
{
_LOG.severe(cnfe);
}
catch (InstantiationException ie)
{
_LOG.severe(ie);
}
catch (IllegalAccessException iae)
{
_LOG.severe(iae);
}
}
return null;
}
|
public static UIViewRoot restoreViewRoot(FacesContext context,
Object saved) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
if (saved == null)
throw new NullPointerException();
PageState viewState = (PageState) saved;
UIViewRoot root = viewState.popRoot(context);
if (root != null)
{
return root; // bug 4712492
}
Object structure = viewState.getStructure();
Object state = viewState.getState();
root = (UIViewRoot)
((Structure) structure).createComponent();
if (state != null)
root.processRestoreState(context, state);
return root;
}
|
public static void reuseRequestTokenForResponse(ExternalContext ec) {
ec.getRequestMap().put(_REUSE_REQUEST_TOKEN_FOR_RESPONSE_KEY, Boolean.TRUE);
}
Mark the the incoming request token should be used for the response |
public static Object saveComponentTree(FacesContext context,
UIComponent component) {
// Don't remove transient components...
Object structure = new Structure(component);
Object state = component.processSaveState(context);
return new PageState(context, structure, state, null);
}
Save a component tree as an Object. |
public SerializedView saveSerializedView(FacesContext context) {
assert(context != null);
if(isSavingStateInClient(context))
{
return _saveSerializedView(context);
}
return _delegate.saveSerializedView(context);
}
|
public Object saveView(FacesContext context) {
assert(context != null);
if(isSavingStateInClient(context))
{
SerializedView view = _saveSerializedView(context);
return new Object[]{view.getStructure(), view.getState()};
}
return super.saveView(context);
}
|
public static Object saveViewRoot(FacesContext context,
UIViewRoot root) {
_removeTransientComponents(root);
Object structure = new Structure(root);
Object state = root.processSaveState(context);
return new PageState(context, structure, state, root);
}
Save a view root. Doesn't return a SerializedView because
SerializedView is a non-static inner class, and this needs
to be a static method. |
public void writeState(FacesContext context,
SerializedView state) throws IOException {
_delegate.writeState(context, state);
}
|