0 Replies Latest reply on Feb 27, 2013 3:15 AM by smoking81

    Problem with a4j:push CDI example from showcase (RF 4.2.0)

    smoking81

      Hi all!

      I am trying to let the RF's a4j:push example from the showcase work on my machine. The application is deployed correctly and I could debug it until the CDI event gets fired, but I cannot see any update in the consumer. Can you please help me to understand what's going wrong with my consumer (or at least to debug it)?

       

      Thanks a lot for your help!

       

       

      Producer JSF:

       

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich">
      
              <h:form>
                  <h:panelGrid columns="4">
                      <h:outputLabel value="Message:" />
                      <h:inputText id="messageInput" styleClass="message" value="#{pushCdiBean.message}">
      
                      </h:inputText>
      
                      <a4j:commandButton value="Send" action="#{pushCdiBean.sendMessage}"
                          execute="@form" render="messageInput" />
      
                      <rich:messages for="messageInput" />
                  </h:panelGrid>
      
      
              </h:form>
          </ui:composition>
      

      Consumer JSF:

       

       

        <?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">
          <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich">
      
              <h:form>
                  <h:panelGrid columns="3">
                      <a4j:push address="pushCdi" 
                          ondataavailable="jQuery('&lt;li /&gt;').prependTo('#messages').text(event.rf.data)" />
                      <ul id="messages" />
                  </h:panelGrid>
              </h:form>
          </ui:composition>
      

      Bean:

       

       

        import java.io.Serializable;
          import javax.enterprise.context.RequestScoped;
          import javax.enterprise.event.Event;
          import javax.inject.Inject;
          import javax.inject.Named;
      
          import org.richfaces.cdi.push.Push;
      
          /**
           * @author <a href="http://community.jboss.org/people/lfryc">Lukas Fryc</a>
           */
          @Named
          @RequestScoped
          public class PushCdiBean implements Serializable{
      
           private static final long serialVersionUID = 1L; 
              private String message;
      
              @Inject
              @Push(topic = "pushCdi")
              Event<String> pushEvent;
      
              /**
               * Sends message.
               * 
               * @param message
               *            to send
               */
              public void sendMessage() {
                  this.pushEvent.fire(this.message);
                  this.message = "";
              }
      
              public String getMessage() {
                  return this.message;
              }
      
              public void setMessage(String message) {
                  this.message = message;
              }
          }
      

      web.xml:

       

       

        <?xml version="1.0" encoding="UTF-8"?>
          <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
              <context-param>
                  <param-name>javax.faces.PROJECT_STAGE</param-name>
                  <param-value>Development</param-value>
              </context-param>
               <context-param>
              <param-name>org.atmosphere.useBlocking</param-name>
              <param-value>true</param-value>
           </context-param>
      
              <servlet>
                  <servlet-name>Faces Servlet</servlet-name>
                  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                  <load-on-startup>1</load-on-startup>
              </servlet>
      
              <servlet>
          <servlet-name>Push Servlet</servlet-name>
          <servlet-class>org.richfaces.webapp.PushServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
          <async-supported>true</async-supported>
          </servlet>
              <servlet-mapping>
                  <servlet-name>Faces Servlet</servlet-name>
                  <url-pattern>/faces/*</url-pattern>
              </servlet-mapping>
              <servlet-mapping>
                      <servlet-name>Faces Servlet</servlet-name>
                      <url-pattern>*.xhtml</url-pattern>
              </servlet-mapping>
      
      
              <session-config>
                  <session-timeout>
                      30
                  </session-timeout>
              </session-config>
              <welcome-file-list>
                  <welcome-file>faces/index.xhtml</welcome-file>
              </welcome-file-list>
          </web-app>
      

      pom.xml:

       

          <dependencyManagement>
      
                  <dependencies>
                      <dependency>
                          <groupId>org.richfaces</groupId>
                          <artifactId>richfaces-bom</artifactId>
                          <version>4.2.0.Final</version>
                          <scope>import</scope>
                          <type>pom</type>
                      </dependency>
          ....
           </dependencyManagement>
              <dependencies>
            ...  
                  <dependency>
                      <groupId>org.richfaces.core</groupId>
                      <artifactId>richfaces-core-api</artifactId>
      
                  </dependency>
                  <dependency>
                      <groupId>org.richfaces.core</groupId>
                      <artifactId>richfaces-core-impl</artifactId>
      
                  </dependency>
                  <dependency>
                      <groupId>org.richfaces.ui</groupId>
                      <artifactId>richfaces-components-api</artifactId>
      
                  </dependency>
                  <dependency>
                      <groupId>org.richfaces.ui</groupId>
                      <artifactId>richfaces-components-ui</artifactId>
      
                  </dependency>
                  <dependency>
                      <groupId>org.atmosphere</groupId>
                      <artifactId>atmosphere-runtime</artifactId>
                  </dependency>
              </dependencies>