title: JSF PrimeFaces Ajax variable reset
body: <p>I want a countdown in my JSF-Page, and i solved it with <code>&lt;p:poll&gt;</code> from Primefaces.</p>
  
  <p>I have following source:</p>
  
  <p>JSF-Page:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;h:outputText id="timeLeft" value="#{bean.secondsToGo}" /&gt;
      &lt;p:poll interval="1" listener="#{bean.countdown}" stop="#{bean.secondsToGo&lt;0}" update="timeLeft" /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>BEAN (view-scoped):</p>
  
  <pre><code>private int secondsToGo;
  public void setValues(){ //prerenderview-event )
      if(FacesContext.getCurrentInstance().isPostback()){
          System.out.println("POSTBACK RECOGNIZED");
          return; //ignore ajax-calls!
      }
      ...
      secondsToGo=74; //(the value depends from a GET-parameter
      System.out.println("INIT: " + secondsToGo);
  }
  
  public void countdown(){
      System.out.println("BEFORE: " + secondsToGo);
      secondsToGo--;
      System.out.println("AFTER: " + secondsToGo);
  }
  </code></pre>
  
  <p>The funny or weird thing is that when the ajax-call is performed (p:poll), the secondsToGo is resetted to 0:</p>
  
  <p>INIT: 74 //correct value</p>
  
  <p>BEFORE: 0</p>
  
  <p>AFTER: -1</p>
  
  <p>Why?</p>