title: Auto refresh in JSF using Ajax
body: <p>I am using this code in my .xhtml page</p>
  
  <p>In head tag, i am using for refresh purpose,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     alert("hi");
     setInterval(function() { 
      document.getElementById('myForm:btnLoadData').submit();
      alert("Hello");
      }, 3000);
  &lt;/script&gt;
  </code></pre>
  
  <p>and inside <strong>ui:define</strong> tag i am writing this code.</p>
  
  <pre><code>&lt;h:panelGroup id="divData" layout="block"&gt;
  
  //my jsf code..................
  
  &lt;/h:panelGroup&gt;
  
  &lt;h:form id="myForm"&gt;
  &lt;h:commandButton id="btnLoadData" value="Hidden" style="display:none"&gt;
      &lt;f:ajax execute="@form" render=":divData" /&gt;
  &lt;/h:commandButton&gt;
  &lt;/h:form&gt; 
  </code></pre>
  
  <p>After all this I am not getting any error, but the hidden button is not working as desired in script. Even I cant see the alert("Hello"). </p>
  
  <blockquote>
    <p>Update: I can see the first alert("hi") but not alert("Hello")</p>
  </blockquote>
  
  <p>I am newbie in jsf. I have to implement polling type thing or auto refresh.
  I also tried <a href="http://www.primefaces.org/showcase/ui/ajax/poll.xhtml" rel="nofollow">this example</a>. But its not working.</p>
  
  <p><strong>Problem 2</strong>
  I dont know that much jsf. At some places I am using normal HTML tags. I dont know why URL is not showing the page name. Its always like host/myProjectName. I am expecting host/projectName/Login.xhtml or host/projectName/SomeOtherPage.xhtml
  Even browser back button or reload for that particular page not works. It reloads from first page of my project i-e Login page. Are both problems interrelated. How can I handle this.</p>
  
  <p>Somebody please help me with the problem.</p>