0 Replies Latest reply on Oct 26, 2007 6:21 AM by Julien Martin

    Working example of a4j:push for the wiki [HELP]

    Julien Martin Expert


      I am trying to construct a working example of a4j:push that I might post on the wiki/cookbook and here what I came up with:

      The javabean (REQUEST SCOPE)

      package pack;
      import java.util.Date;
      import java.util.EventListener;
      import java.util.EventObject;
      import org.ajax4jsf.event.PushEventListener;
       * @author Administrator
      public class TheBean {
       /** Creates a new instance of TheBean */
       public TheBean() {
       private Date date;
       private PushEventListener listener = new MyPushEventListener();
       public void addListener(EventListener listener) {
       synchronized (listener) {
       if (this.listener != listener) {
       this.listener = (PushEventListener) listener;
       public Date getDate() {
       return new Date();
       public void push() {
       synchronized (this.listener) {
       this.listener.onEvent(new EventObject(this));
      class MyPushEventListener implements PushEventListener {
       public void onEvent(EventObject evt) {

      and the fist jsp: receiver

       <a4j:status startText="in progress" stopText="done"/>
       <a4j:push reRender="msg" eventProducer="#{theBean.addListener}" interval="100"/>
       <a4j:outputPanel id="msg" ajaxRendered="true">
       <h:outputText value="#{theBean.date}">
       <f:convertDateTime type="time"/>
       <a4j:log level="ALL" popup="true" hotkey="L"/>

      The receiver
       <a4j:status startText="in progress" stopText="done"/>
       <a4j:commandButton value="Push!!" action="#{theBean.push}"/>
       <a4j:log level="ALL" popup="true" hotkey="L"/>

      My msg is not updated...

      Can anyone help,