我正在尝试在对话框中使用 p:push 并且在 chrome 中出现此错误:
Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 primefaces.js.xhtml:1
PrimeFaces.widget.PrimeWebSocket.send primefaces.js.xhtml:1
PrimeFaces.ajax.AjaxUtils.handleResponse primefaces.js.xhtml:1
PrimeFaces.ajax.AjaxResponse primefaces.js.xhtml:1
k.success primefaces.js.xhtml:1
b.Callbacks.bv jquery.js.xhtml:16
b.Callbacks.bE.fireWith jquery.js.xhtml:16
bF jquery.js.xhtml:23
b.ajaxTransport.send.bv
推送服务器在码头 8.1.5.v20120716 的 9090 端口上运行 这是我的应用程序 web.xml 的一部分:
<context-param>
<param-name>primefaces.PUSH_SERVER_URL</param-name>
<param-value>ws://localhost:9090/push/</param-value>
</context-param>
这是推送服务器的 web.xml 的内容:
<display-name>PUSH SERVER</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>channels</param-name>
<param-value>importador</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/push/*</url-pattern>
</servlet-mapping>
对话内容:
...
<h:panelGroup layout="block" styleClass="hrgi-div-form clearfix">
<h:panelGroup id="painel" layout="block">
<p:progressBar widgetVar="barraProgressoImportador" ajax="true"
value="#{modeloPopupImportadorImediatoNFe.porcentagem}"/>
<h:outputText value="#{modeloPopupImportadorImediatoNFe.mensagem}"/>
</h:panelGroup>
<p:push channel="importador" onmessage="atualizarPorcentagemImportacao"/>
</h:panelGroup>
...
调用的 javascript 代码(仅显示警报):
function atualizarPorcentagemImportacao(evt, data){
alert("importado "+data);
}
最后是尝试推送的代码:
public void abrir() {
...
modeloPopup.setContext(RequestContext.getCurrentInstance());
modeloPopup.getContext().push("importador", 0);
}
难道我做错了什么??
添加 如果它可能有用,这是我的推送服务器的 pom.xml
<parent>
<artifactId>modulos-web</artifactId>
<groupId>com.hrgi.web</groupId>
<version>0.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>push-server</artifactId>
<packaging>war</packaging>
<name>push-server</name>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-websocket</artifactId>
<version>8.1.5.v20120716</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
<finalName>push-server</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>9090</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
</build>