title: How to use JSF(Primefaces) ajax Listener?
body: <p>I am having problem in using the ajax tag of the listener to invoke a method in the managed bean. The following code does not work. Although the ajax is invoking the JavaScript method <code>view.show()</code>, it does not invoke the managedbean method in the listener property.</p>
  
  <pre><code>&lt;p:dataTable id="dataTable" var="customersFeedback"
    value="#{customersFeedbackController.allReadFeedbacks}"  
    widgetVar="reservationTable"
    selectionMode="single" 
    selection="#{customersFeedbackController.customersFeedback}" 
    rowKey="#{customersFeedback.id}"&gt;
  
     &lt;p:ajax event="rowSelect" update=":viewFeedbackForm:viewDlg" listener="#
       {customersFeedbackController.setMessageAsRead()}" oncomplete="view.show()"/&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>Here is my managedbean. The update method is simply a method to update the CustomerFeedback object in the database. </p>
  
  <pre><code>@ManagedBean(name = "customersFeedbackController")
  public class CustomersFeedbackController implements Controller&lt;CustomersFeedback&gt; {
  
      private CustomersFeedback customersFeedback = new CustomersFeedback();
      // other fields here
  
      @Override
      public void update() {
          customersFeedbackDao.update(customersFeedback);
      }
  
      public void setMessageAsRead() {
          customersFeedback.setStatus("Read");
          this.update();
          System.out.println("Method Executed"); // Just a test
      }
  
      // Other methods here
  
  }
  </code></pre>
  
  <p>am I doing something wrong? If there is, feel free to correct me. Thanks.</p>