我正在尝试使用p:按下对话框,我在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
推送服务器在端口9090的jetty 8.1.5.v20120716中运行 这是我的应用程序的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);
}
我做错了吗?
ADDED 的 如果它有用,这是我的推送服务器的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>
答案 0 :(得分:1)
您需要以下设置才能完成推送工作。
在pom.xml中:
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>1.0.0.RC1</version>
</dependency>
在web.xml中推送servlet设置:
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
在这些推动必须奏效之后。
您可以查看primefaces_user_quide文章以获取更多完整信息