title: How do I use ajax to automatically refresh my JSF page?
body: <p><strong>Scenario</strong> </p>
  
  <p>The Problem I'm having is that I have no clue how to automatically refresh an <code>&lt;f:ajax&gt;</code> JSF component. Is there any way to do this without primefaces? I'm stuck only using the resources that JEE6 incorporates (no other libraries). will <code>&lt;f:ajax&gt;</code> be able to do this. Is there an attribute that <code>&lt;f:ajax&gt;</code> has the will automatically update when the beans value changes?</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>When I can only get <code>&lt;f:ajax&gt;</code> to work on a button click. </p>
  
  <p><strong>Desired Goal</strong></p>
  
  <p>Have <code>&lt;f:ajax&gt;</code> automatically refresh every N seconds</p>
  
  <p>Code I'm working with:</p>
  
  <p><strong>helloAjax.html</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"      
        xmlns:h="http://java.sun.com/jsf/html"&gt;
  
      &lt;h:body&gt;
  
          &lt;h3&gt;Ajax Example&lt;/h3&gt;
  
          &lt;h:form&gt;   
             &lt;h:inputText id="name" value="#{ajaxBean.name}"&gt;&lt;/h:inputText&gt;
             &lt;h:commandButton value="Submit"&gt;
               &lt;f:ajax execute="name" render="output" listener="#{ajaxBean.name}" onchange="Submit" /&gt;
             &lt;/h:commandButton&gt;
             &lt;h2&gt;&lt;h:outputText id="output" value="#{ajaxBean.sayWelcome}" /&gt;&lt;/h2&gt; 
          &lt;/h:form&gt;
  
      &lt;/h:body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>AjaxBean.java:</strong></p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class AjaxBean
  {
      private String name ="";
  
      public String getName() 
      {
         return name;
      }
      public void setName(String name) 
      {
         this.name = name;
      }
      public String getSayWelcome()
      {
  
         if(name.equals("") || name ==null)
         {
             return "";
         }
         else
         {
           return "From AjaxBean: "+new java.util.Date().getTime() +" "+ name; 
         }
      }
  }
  </code></pre>