0 Replies Latest reply on Nov 5, 2011 7:38 AM by Hauke Gulich

    a4j:push address attribute value

    Hauke Gulich Newbie

      Hello,

       

      I have a simple question, what does I need to put into the attribute of a4j:push?

      I read the chat-example, but I don't get it.

       

      What I want is that as soon as somebody write a message to the topic notify, some components should be rerendered.

       

      I am using richfaces 4 and JBoss 7, so I configured a topic like this inside my standalone.xml file

       

       

      {code:xml}

                  <jms-topic name="notify">
                      <entry name="topic/notify"/>
                  </jms-topic>

      {code}

       

      And I created a simple xhtml file like this:

       

       

      {code:xml}

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:a4j="http://richfaces.org/a4j"

          xmlns:rich="http://richfaces.org/rich">

       

      <f:view>

       

          <h:head>

              <title>Testing</title>

          </h:head>

       

          <h:body>

              <h:form>

       

                  <rich:panel styleClass="navigationPanel" header="Navigation">

       

                      <h:outputText id="dummytext" value="Value is #{testing.randomValue}"></h:outputText>

       

                  </rich:panel>

       

                  <a4j:push address="@notify">

                      <a4j:ajax event="dataavailable" render="dummytext" execute="@none" />

                  </a4j:push>

       

              </h:form>

       

          </h:body>

      </f:view>

      </html>

      {code}

       

       

      And my bean looks like this

       

       

      {code}

      package de.hauke.client.bean;

       

      import javax.faces.bean.ManagedBean;

      import javax.faces.bean.SessionScoped;

       

      @ManagedBean (name="testing")

      @SessionScoped

      public class TestingBean {

       

          private String randomValue;

       

          public String getRandomValue() {

             

              int zahl = (int)(Math.random() * 1000 + 1);

             

              return String.valueOf(zahl);

          }

       

          public void setRandomValue(String randomValue) {

              this.randomValue = randomValue;

          }

         

      }

      {code}

       

       

      So the value displayed on the page should be change if a message arrives.

       

      What do I have to write at the address-attribute in order to get this simple thing to work?

       

      Many greetings,

      Hauke