PhotoAlbum Application Download Support Developer Guide
Resources/Beans Handling
Ajax Miscellaneous
Push and Table cells updates
Tag Information

The <a4j:push> periodically perform AJAX request to server, to simulate 'push' data.

The main difference between <a4j:push> and <a4j:poll> components is that <a4j:push> makes request to minimal code only (not to JSF tree) in order to check the presence of messages in the queue. If the message exists the complete request will be performed. The component doesn't poll registered beans but registers EventListener which receives messages about events.

Attribute 'interval' is used as for poll component. It specifies the interval in ms. for call push request. Simple example of usage:

Page code:
<a4j:push reRender="msg" eventProducer="#{messageBean.addListener}" interval="3000"/>

Code for registration of listener:
public void addListener(EventListener listener) {
synchronized (listener) {
    if (this.listener != listener) {
    this.listener = (PushEventListener) listener;

Component can get message using current code:
System.out.println("event occurs");
synchronized (listener) {
    listener.onEvent(new EventObject(this));

Thus, component 'push' uses asynchronous model instead of polls.

There is simple Push example using Runabble interface.

When you hit Start button new Thread will be started and alive for a minute. It will generate random Uuid once in a ten seconds.

Push component will fire the request after uuid generation event sent and update the output field displaying new uuid value.

Push Demo
Push Example
Press Start to run push example

View Source

View Source
RichFaces Wiki RichFaces Project Site