Home:ALL Converter>Can't use primefaces push

Can't use primefaces push

Ask Time:2012-09-22T02:32:54         Author:brevleq

Json Formatter

I'm trying use p:push in a dialog and I'm getting this error in 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

Push server is running in jetty 8.1.5.v20120716 at port 9090 This is part of web.xml of my application:

<context-param>
       <param-name>primefaces.PUSH_SERVER_URL</param-name>
       <param-value>ws://localhost:9090/push/</param-value>
</context-param>

this is the content of web.xml of push server:

<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>

the content of dialog:

...
<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 code that is called (just show an alert):

function atualizarPorcentagemImportacao(evt, data){
    alert("importado "+data);
}

and finally the code that try push:

public void abrir() {
        ...
        modeloPopup.setContext(RequestContext.getCurrentInstance());
        modeloPopup.getContext().push("importador", 0);
}

Am I doing something wrong??

ADDED If it could be useful, this is my pom.xml of push-server

<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>

Author:brevleq,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12536230/cant-use-primefaces-push
yy