Version 3



    RF team has added a new hot feature which is push with CDI, but I tried to use it and i faced a troublesome message (Topic 'my topic name' is not configured), my enviroment :

    -JBoss AS 6.0 final

    -JDK 1.6.0-24

    -RichFaces 4.1 Final


    Refer to these sources for more information:

    RichFaces Component Guide: a4j:push component

    Starting with RichFaces Push on Various Servlet Containers

    RichFaces Developer Guide


    so i asked for TopicContext help to complete my task, here what you need to do to make a4j:push work using CDI :


    1-add context parameters to your web.xml :




    2-find the attached file (atmosphere dependencies.rar), it contains 5 jars for atmosphere push framework, copy them into your WEB-INF/lib directory.



    public class PushBean implements Serializable {
              private static final long serialVersionUID = 1L; 
              private static final String CDI_PUSH_TOPIC = "pushCdi";
              private String userIdentifier;
              private String message; 
              @Push(topic=CDI_PUSH_TOPIC, subtopic="#{pushBean.userIdentifier}")//i thought that the topic is initialized with this ?!
              private Event<String> pushEvent;
              public void init() {
                             if(userIdentifier == null) {
                                            userIdentifier = UUID.randomUUID().toString().replace("-", ""); 
              TopicsContext topicsContext = TopicsContext.lookup();
              topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));//initialize the topic and make the troublesome message disappears
              public void sendMessage() throws MessageException {
              public String getUserIdentifier() {
                        return userIdentifier;
              public String getMessage() {
                        return message;
              public void setMessage(String message) {
                        this.message = message;


    4-producer.xhtml source code:

    <h:form id="prodForm">
                                            <h:outputText id="uid" value="uid: #{pushBean.userIdentifier}" />
                                            <h:inputText id="msg" value="#{pushBean.message}" />
                                            <a4j:commandButton id="sendMsg" 


    important:use uid as a parameter to invoke consumer.xhtml page, ex :http://localhost:8080/rf4/faces/consumer.xhtml?uid=c59d249427544df286782765379c4647

    this will ensure that each user has his own topic.


    5-consumer.xhtml code:


    <h:form id="conForm">
                        <rich:panel style="width:150px" header="messages">
                                  <a4j:push id="consumer" 
                                                        ondataavailable="jQuery('&lt;li /&gt;').prependTo('#messages').text("/>
                                  <ul id="messages"/>


    try it out .