title: JSF form post with AJAX
body: <p>I want the following form to use AJAX. So the comments are shown after clicking the command button and without reloading the page. What needs to be changed, using Java Server Faces 2.0?</p>
  
  <p>Functionality: This form provides an inputText to define a topic. After pressing the commandButton, it is searched for comments regarding this topic. Comments are shown in a dataTable, if there are any. Otherwise <em>Empty</em> is shown.</p>
  
  <pre><code>&lt;h:form id="myForm"&gt;
      &lt;h:outputLabel value="Topic:" for="topic" /&gt;
      &lt;h:inputText id="topic" value="#{commentManager.topic}" /&gt;
      &lt;h:commandButton value="read" action="#{commentManager.findByTopic}" /&gt;
      &lt;h:panelGroup rendered="#{empty commentManager.comments}"&gt;
          &lt;h:outputText value="Empty" /&gt;
      &lt;/h:panelGroup&gt;
      &lt;h:dataTable
          id="comments"
          value="#{commentManager.comments}"
          var="comment"
          rendered="#{not empty commentManager.comments}"
      &gt;
          &lt;h:column&gt;
              &lt;h:outputText value="#{comment.content}"/&gt;
          &lt;/h:column&gt;
      &lt;/h:dataTable&gt;
  &lt;/h:form&gt;
  </code></pre>