docs: @Override
      public UIViewRoot restoreView(FacesContext context, String viewId)
      {
          checkNull(viewId, "viewId");
          // Currently there is no way, in which UIDebug.debugRequest(context)
          // can create debug information and return true at this point,
          // because this method is only accessed if the current request
          // is a postback, which will never be true for a debug page.
          // The only point where valid debug output can be produced by now
          // is in createView() -= Jakob Korherr =-
          //if (UIDebug.debugRequest(context))
          //{
          //    return new UIViewRoot();
          //}
  
          //else if (!_buildBeforeRestore)
          //{
          
          // When partial state saving is not used, createView() is not called. To ensure
          // everything is in place it is necessary to calculate the resource library 
          // contracts and set them into facesContext.
          ViewDeclarationLanguage vdl = context.getApplication().getViewHandler().
              getViewDeclarationLanguage(context, viewId);
          List<String> contracts = vdl.calculateResourceLibraryContracts(
              context, viewId);
          context.setResourceLibraryContracts(contracts);
          
          // JSF 2.2 stateless views
          // We need to check if the incoming view is stateless or not and if that so rebuild it here
          // note we cannot do this in DefaultFaceletsStateManagementStrategy because it is only used
          // when PSS is enabled, but stateless views can be used without PSS. If the view is stateless,
          // there is no need to ask to the StateManager.
          Application application = context.getApplication();
          ViewHandler applicationViewHandler = application.getViewHandler();
          String renderKitId = applicationViewHandler.calculateRenderKitId(context);
  
          ResponseStateManager manager = getRenderKitFactory().getRenderKit(
              context, renderKitId).getResponseStateManager();
          
          if (manager.isStateless(context, viewId))
          {
              // Per the spec: build the view.
              UIViewRoot view = null;
              try
              {
                  ViewMetadata metadata = vdl.getViewMetadata (context, viewId);
                  if (metadata != null)
                  {
                      view = metadata.createMetadataView(context);
                  }
                  if (view == null)
                  {
                      view = context.getApplication().getViewHandler().createView(context, viewId);
                  }
                  context.setViewRoot (view); 
                  boolean oldContextEventState = context.isProcessingEvents();
                  try 
                  {
                      context.setProcessingEvents (true);
                      vdl.buildView (context, view);
                      // If the view is not transient, then something is wrong. Throw an exception.
                      if (!view.isTransient())
                      {
                          throw new FacesException ("unable to create view \"" + viewId + "\"");
                      } 
                  }
                  finally
                  {
                          context.setProcessingEvents (oldContextEventState);
                  } 
              }
              catch (Throwable e)
              {
                  throw new FacesException ("unable to create view \"" + viewId + "\"", e);
              }
              FaceletsViewDeclarationLanguageUtils.markRenderedResources(context, view);
              return view;
          }
          else
          {
              UIViewRoot root = super.restoreView(context, viewId);
              FaceletsViewDeclarationLanguageUtils.markRenderedResources(context, root);
              return root;
          }
      }