title: Primefaces commandButton calls action method on page refresh
body: <p><strong>Completely edited:</strong>
  Maybe I was mixing problems and misinterpreted. After simplifying my code the question simplifies to: How can I prevent the <code>&lt;p:commandButton&gt;</code> from executing it's action method on page refresh (like when you hit F5 inside browser window)?</p>
  
  <p>JSF Code:  </p>
  
  <pre><code>   &lt;html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:p="http://primefaces.org/ui"&gt;
      &lt;h:body&gt;
          &lt;h:form&gt;
              &lt;h:outputText value="#{bugBean.number}" /&gt;
              &lt;h:outputText value="#{bugBean.isComplete()}" /&gt;
              &lt;p:commandButton id="entryCommand" value="add"
                  action="#{bugBean.increase()}" update="@form" oncomplete="#{bugBean.complete()}"/&gt;
          &lt;/h:form&gt;
      &lt;/h:body&gt;
      &lt;/html&gt; 
  </code></pre>
  
  <p>backing bean code:  </p>
  
  <pre><code>  package huhu.main.managebean;
  import java.io.Serializable;
  import javax.enterprise.context.SessionScoped;
  import javax.inject.Named;
  
  @Named
  @SessionScoped
  public class BugBean implements Serializable {
  
     private static final long serialVersionUID = 1L;
     private int number;
     private boolean isComplete = false;
  
     public void increase(){
        number++;
     }
  
     public void complete(){
        isComplete = true;
     }
  
     public int getNumber() {
        return number;
     }
  
     public void setNumber(int number) {
        this.number = number;
     }
  
     public boolean isComplete() {
        return isComplete;
     }
  
     public void setComplete(boolean isComplete) {
        this.isComplete = isComplete;
     }
  }
  </code></pre>
  
  <p><strong>Update:</strong>
  Even if I remove the <code>oncomplete</code> stuff like this an click the <code>&lt;p:commandButton&gt;</code> just once, the counter goes up on every page refresh.</p>
  
  <pre><code>&lt;h:form&gt;
          &lt;h:outputText value="#{bugBean.number}" /&gt;
          &lt;p:commandButton id="entryCommand" value="add"
              action="#{bugBean.increase()}" update="@form"/&gt;
      &lt;/h:form&gt;
  </code></pre>