0

我正在尝试在对话框中使用 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>
4

1 回答 1

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 文档以获取更多完整信息

于 2012-10-01T08:38:54.883 回答