Auto refresh in JSF using Ajax

时光毁灭记忆、已成空白 提交于 2019-12-08 04:11:29

问题


I am using this code in my .xhtml page

In head tag, i am using for refresh purpose,

<script type="text/javascript">
   alert("hi");
   setInterval(function() { 
    document.getElementById('myForm:btnLoadData').submit();
    alert("Hello");
    }, 3000);
</script>

and inside ui:define tag i am writing this code.

<h:panelGroup id="divData" layout="block">

//my jsf code..................

</h:panelGroup>

<h:form id="myForm">
<h:commandButton id="btnLoadData" value="Hidden" style="display:none">
    <f:ajax execute="@form" render=":divData" />
</h:commandButton>
</h:form> 

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").

Update: I can see the first alert("hi") but not alert("Hello")

I am newbie in jsf. I have to implement polling type thing or auto refresh. I also tried this example. But its not working.

Problem 2 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.

Somebody please help me with the problem.

来源:https://stackoverflow.com/questions/26151422/auto-refresh-in-jsf-using-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!