@Override
public UIViewRoot restoreView(FacesContext facesContext, String viewId, String renderKitId)
{
if (log.isLoggable(Level.FINEST)) log.finest("Entering restoreView - viewId: "+viewId+" ; renderKitId: "+renderKitId);
UIViewRoot uiViewRoot = null;
ViewDeclarationLanguage vdl = facesContext.getApplication().
getViewHandler().getViewDeclarationLanguage(facesContext,viewId);
StateManagementStrategy sms = null;
if (vdl != null)
{
sms = vdl.getStateManagementStrategy(facesContext, viewId);
}
if (sms != null)
{
if (log.isLoggable(Level.FINEST)) log.finest("Redirect to StateManagementStrategy: "+sms.getClass().getName());
uiViewRoot = sms.restoreView(facesContext, viewId, renderKitId);
}
else
{
RenderKit renderKit = getRenderKitFactory().getRenderKit(facesContext, renderKitId);
ResponseStateManager responseStateManager = renderKit.getResponseStateManager();
Object state;
if (isSavingStateInClient(facesContext))
{
if (log.isLoggable(Level.FINEST)) log.finest("Restoring view from client");
state = responseStateManager.getState(facesContext, viewId);
}
else
{
if (log.isLoggable(Level.FINEST)) log.finest("Restoring view from session");
Integer serverStateId = getServerStateId((Object[]) responseStateManager.getState(facesContext, viewId));
state = getSerializedViewFromServletSession(facesContext, viewId, serverStateId);
}
if (state != null) {
Object[] stateArray = (Object[])state;
TreeStructureManager tsm = new TreeStructureManager();
uiViewRoot = tsm.restoreTreeStructure(stateArray[0]);
if (uiViewRoot != null) {
facesContext.setViewRoot (uiViewRoot);
uiViewRoot.processRestoreState(facesContext, stateArray[1]);
}
}
}
if (log.isLoggable(Level.FINEST)) log.finest("Exiting restoreView - "+viewId);