title: p:commandButton action method invoked multiple times on single click
body: <p>I am using JSF 2.2/PrimeFaces 5.1. I've a command button which performs a search and adds a faces message.</p>
  
  <p>XHTML:</p>
  
  <pre><code>&lt;p:commandButton id="search" value="Search" 
      update="emptyId,empAtendanceTable,msgDialog" 
      action="#{attendanceBean.buttonAction(actionEvent)}" /&gt;
  </code></pre>
  
  <p>Bean:</p>
  
  <pre><code>public void buttonAction(ActionEvent actionEvent) {
      if (fromDate.after(todate)) {
          addMessage("To date cannot be after from date");
      }
  }
  </code></pre>
  
  <p>However, when I click the button, the action method is invoked multiple times and causes the message being added multiple times.</p>
  
  <p><img src="https://i.stack.imgur.com/4a5cT.png" alt="enter image description here"></p>
  
  <p>How is this caused and how can I solve it? The action method needs to be invoked only once.</p>