org.wicketstuff.push
Interface IChannelService

All Known Implementing Classes:
CometdService, TimerChannelService

public interface IChannelService

A service providing channel based communication facility in wicket based applications.

Implementation of this interface are the basis of a channel based communication implementation. You usually store one IChannelService implementation in your application instance, and then delegate all your channel related operations to this service, allowing very easy switching between channel communication implementations.

Here is how you usually use an IChannelService implementation:

  IChannelService channelService = MyApplication.get().getChannelService();
   // I want to send an event when i click a button
  [...]
    onClick(AjaxRequestTarget target){
      channelService.publish(new ChannelEvent("channel"));
    }
  [...]

  // All pages listening this event should add
  [...]
    channelService.addChannelListener(this, "channel", new IChannelListener() {
      public void onEvent(String channel, Map datas, IChannelTarget target){
            target.[...]
          }
    });
  [...]
 

Author:
Xavier Hanin
See Also:
TimerChannelService, CometdService, IChannelTarget

Method Summary
 void addChannelListener(org.apache.wicket.Component component, java.lang.String channel, IChannelListener listener)
          Adds a behavior to the given component so that it will be notified of ChannelEvents.
 void publish(ChannelEvent event)
          Publishes a channel event which will be sent to the channel listeners.
 

Method Detail

addChannelListener

void addChannelListener(org.apache.wicket.Component component,
                        java.lang.String channel,
                        IChannelListener listener)
Adds a behavior to the given component so that it will be notified of ChannelEvents.

Usually the component if a Page, even if it's not mandatory. Indeed the components reacting to the event are defined in the IChannelListener, by calling IChannelTarget methods. Hence any component on the page can serve as the host of the behavior, as soon as it is visible.

Parameters:
component - the component to which the behavior should be added
channel - the channel for which the listener should be notified
listener - the IChannelListener which should be notified of ChannelEvents

publish

void publish(ChannelEvent event)
Publishes a channel event which will be sent to the channel listeners.

Parameters:
event - the event to publish to the listeners


Copyright © 2010. All Rights Reserved.