title: Validation on page refresh
body: <p>my input fields have an <code>&lt;f:ajax&gt;</code> object attached to make validation via pressing TAB possible:</p>
  
  <pre><code>&lt;h:inputText id="input2" value="#{bean.property}"&gt;
      &lt;f:validator validatorId="customValidator" /&gt;
      &lt;f:ajax execute="@form" render="@this" /&gt;
  &lt;/h:inputText&gt;
  </code></pre>
  
  <p>If there are any validation errors, they will be displayed via a custom component similar to <code>&lt;h:messages&gt;</code> and the input boxes will be styled via a custom <code>PhaseListener</code>.</p>
  
  <p>I have implemented a custom Faces Validator to skip validation:</p>
  
  <pre><code>public class CustomValidator {
  
  public void validate(FacesContext context, UIComponent component,
          Object value) throws ValidatorException {
      if (skipValidation(context)) {
          return;
      }
      //Validation code goes here
  }
  </code></pre>
  
  <p>This gives me the option to skip bean validation based on some condition, e.g. switching to another editor view and saving the (maybe wrong) data in the backing bean.</p>
  
  <p>Now, my problem occurs when refreshing the current page (either via pressing F5, hitting the same link in the navigation bar or similar). The obviously wrong data in the backing is displayed correctly, as intended, but it should also be marked as invalid. Thus I need a way to invoke the validation on every page load (currently it's invoked via the <code>&lt;f:ajax&gt;</code> objects only). </p>
  
  <p>I tried fiddling with something like this</p>
  
  <pre><code>&lt;f:ajax event="load" execute="editform" render="editform"/&gt;
  </code></pre>
  
  <p>attached to <code>&lt;h:body&gt;</code>. This works, but the site is drawn twice - which I wouldn't really care if there was no evil flickering due toe the page first being drawn, then being validated &amp; updated via the ajax request. </p>
  
  <p>I've searched for hours for a solution to this problem, maybe I just searched in the wrong direction. Any suggestions on how to fix this?</p>