-
Notifications
You must be signed in to change notification settings - Fork 297
Push
NOTE: this documentation applies to wicket push version 1.4.13 or higher.
The Wicket Push project provides support for Reverse AJAX in Wicket applications and allows them to "push" partial Web page updates to the Web browser.
The push projects comes with two implementations:
-
push-timer: a polling based approach where the web page continuously polls the server for page updates via AJAX (similar to
AjaxSelfUpdatingTimerBehavior
) -
push-cometd: the web pages connects to the web application via a stateful Cometd channel on which the server sends update requests to the browser on demand. Note: Cometd requires the Servlet 3.0 specification.
-
push-core
-
push-timer
-
push-cometd
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>push-timer</artifactId>
<version>1.4.14</version>
</dependency>
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>push-cometd</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<repository>
<id>wicketstuff-core-snapshots</id>
<url>ttps://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
The general usage pattern of wicket-push is like this:
-
Instantiate a Push event handler containing the logic to update the UI when a Push event - usually an event raised by a background service, e.g. chat service - occurs.
-
Obtain a reference to a Push service implementation in your Wicket Panel.
-
Install a push channel with this push event handler into one of the panel's components. This will add a Push behavior to that component.
-
You add a listener to your (asynchronous) background service and forward the raised events via the Push service to the Push event handler. This will ensure that the update code is handled in the right Wicket HTTP request thread.
Here is an example:
/*
* panel constructor
*/
public ChatPanel()
{
// setup UI components ...
/*
* 1. instantiate push event handler
*/
IPushEventHandler handler = new AbstractPushEventHandler<Message>()
{
public void onEvent(final AjaxRequestTarget target, final Message message)
{
// TODO your component update logic goes here...
}
});
/*
* 2. obtain a reference to a Push service implementation
*/
IPushService pushService = CometdPushService.get();
/*
* 3. install push channel into this panel
*/
IPushChannel<Message> pushChannel = pushService.installPushChannel(this, handler);
/*
* 4. connect to the chat service and forward the Message events
*/
IChatService chatService = ServiceLocator.getChatService();
chatService.addListener(new IChatListener() {
public void onMessage(Message msg)
{
if (pushService.isConnected(pushChannel))
// forward the Message event via the push service to the push event handler
pushService.publish(pushChannel, msg);
else
chatService.removeListener(this);
}
});
}
Active:
-
Rodolfo Hansen
-
Sebastian Thomschke
Retired:
- Vincent Demay
-
jdk-1.5-parent/push-parent-jdk-1.5
-
jdk-1.6-parent/push-parent-jdk-1.6
- jdk-1.5-parent/push-parent-jdk-1.5
- jdk-1.6-parent/push-parent-jdk-1.6