jsf - Primefaces Poll component triggers HTTP OPTIONS and Ajax call is not made -
i writing web app homepage needs refresh every second. decided use primefaces poll component make ajax calls periodically.
however call not made on project base url, such as:
http://localhost:8080 but work correctly, when url describes folder structure:
http://localhost:8080/web/index.xhtml project structure:

welcome-file in web.xml:
<welcome-file-list> <welcome-file>/web/index.xhtml</welcome-file> </welcome-file-list> index.xhtml
<?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"> <h:head> </h:head> <h:body> <h:form> <h:outputtext value="#{counterview.number}" id="counternumber"/> <p:poll interval="1" listener="#{counterview.increment}" update="counternumber"/> </h:form> </h:body> </html> counterview.java
@component("counterview") @scope("session") public class counterview { private int number; public int getnumber() { return number; } public void increment() { number++; } } further debugging in firebug shows there's http options method called:

but it's not called http://localhost:8080/web/index.xhtml http://web/index.xhtml , it's aborted after time.
i fix problem forcing redirect address http://localhost:8080/web/index.xhtml i'd know what's causing problem , fix more cleanly.
you're setting absolute path welcome file, noted first / in value:
<welcome-file>/web/index.xhtml</welcome-file> remove relative context path of application:
<welcome-file>web/index.xhtml</welcome-file>
Comments
Post a Comment