if (key == null )
{
// Check if clientWindow is enabled and if the last view key is stored
// into session, so we can use it to chain the precedence in GET-GET
// cases.
ClientWindow clientWindow = context.getExternalContext().getClientWindow();
if (clientWindow != null)
{
key = (SerializedViewKey) viewCollection.
getLastWindowKey(context, clientWindow.getId());
}
else if (isUseFlashScopePurgeViewsInSession(context.getExternalContext()) &&
Boolean.TRUE.equals(context.getExternalContext().getRequestMap()
.get("oam.Flash.REDIRECT.PREVIOUSREQUEST")))
{
key = (SerializedViewKey)
context.getExternalContext().getFlash().get(RESTORED_VIEW_KEY_REQUEST_ATTR);
}
}
}
SerializedViewKey nextKey = getSessionViewStorageFactory().createSerializedViewKey(
context, context.getViewRoot().getViewId(), getNextViewSequence(context));
// Get viewScopeMapId
ViewScopeProxyMap viewScopeProxyMap = null;
Object viewMap = context.getViewRoot().getViewMap(false);
if (viewMap != null)
{
while (viewMap != null)
{
if (viewMap instanceof ViewScopeProxyMap)
{
viewScopeProxyMap = (ViewScopeProxyMap)viewMap;
break;
}
else if (viewMap instanceof FacesWrapper)
{
viewMap = ((FacesWrapper)viewMap).getWrapped();
}
}
}
if (viewScopeProxyMap != null)
{
ViewScopeProviderFactory factory = ViewScopeProviderFactory.getViewScopeHandlerFactory(
context.getExternalContext());
ViewScopeProvider handler = factory.getViewScopeHandler(context.getExternalContext());
viewCollection.put(context, serializeView(context, serializedView), nextKey, key,
handler, viewScopeProxyMap.getViewScopeId());
}
else
{
viewCollection.put(context, serializeView(context, serializedView), nextKey, key);
}
ClientWindow clientWindow = context.getExternalContext().getClientWindow();
if (clientWindow != null)
{
//Update the last key generated for the current windowId in session map
viewCollection.putLastWindowKey(context, clientWindow.getId(), nextKey);
}
// replace the value to notify the container about the change
sessionMap.put(SERIALIZED_VIEW_SESSION_ATTR, viewCollection);
}