title: The earliest moment to visitTree() on fully built Component Tree?
body: <p>Good morning, JSF experts!</p>
  
  <p>Let me fugure out the problem I'm trying to solve. The application has many forms. And elements in forms can be marked to require authorization of users according to 1) set of rights and their conditional combinations configured for this form element and 2) user rights loaded from db.</p>
  
  <p>Solution I'm trying to develop is as follows: I implement custom component, which extends <code>UIComponentBase</code>. In the form's Facelets' markup this custom component would wrap elements under authorization:</p>
  
  <pre><code>&lt;custom:applyRights id="abc"&gt;
      &lt;p:inputText
          id="inputWithRights"
          value="Some placeholder..."
          tabindex="0"/&gt;
  &lt;/custom:applyRights&gt;
  </code></pre>
  
  <p>Then I need to modify component tree. I.e. just after the component tree is built I need to find my <code>&lt;custom:applyRights/&gt;</code>, visit its subtree and either leave components as is, or disable them, or set <code>setRendered( false )</code> etc. The concrete action taken upon a component also depends on the component's type.</p>
  
  <p>Then I imlement <code>PhaseListener</code> with:</p>
  
  <pre><code>@Override
  public PhaseId getPhaseId() {
      return PhaseId.RESTORE_VIEW;
  }
  </code></pre>
  
  <p>In its <code>afterPhase(PhaseEvent phaseEvent)</code> I get current instance of <code>FacesContext</code>, <code>UIViewRoot</code>, build <code>new FullVisitContext(facesContext)</code> and attempt <code>viewRoot.visitTree</code>. </p>
  
  <p>But then only viewRoot gets visited. </p>
  
  <p>What am I doing wrong? Maybe I'm trying to <code>visitTree()</code> too early? Then when should it be done?</p>
  
  <p>Thanks!</p>