Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The feature is enabled by default so unless you want to disable it with getResourceSettings().setUseTimestampOnResources(boolean) or query its state with getResourceSettings().getUseTimestampOnResources() you usually don't have to care about it at all. Timestamping only works when the ResourceReference supports a last modified timestamp and returns a non-null timestamp for method ResourceReference.getLastModified(). This is always true for package resources and wicket:link.

Inter-component events

Wicket 1.5 offers a simple, yet flexible, way for component to communicate with each other in a decoupled manner. The two major interfaces that facilitate this are:

Code Block

/**
 * Objects that can send events
 * 
 * @author Igor Vaynberg (ivaynberg)
 */
public interface IEventSource
{
	/**
	 * Sends an event
	 * 
	 * @param <T>
	 *            tyep of payload
	 * 
	 * @param sink
	 *            object that will receive the event
	 * @param broadcast
	 *            if the object that receives the event needs to broadcast it to others, this is the
	 *            type of broadcast that should be used
	 * @param payload
	 *            event payload
	 */
	<T> void send(IEventSink sink, Broadcast broadcast, T payload);
}

and

Code Block

/**
 * Objects that can receive events
 * 
 * @author Igor Vaynberg (ivaynberg)
 */
public interface IEventSink
{
	/**
	 * Called when an event is sent to this sink
	 * 
	 * @param event
	 */
	void onEvent(IEvent<?> event);
}

.

The classes that implement these interfaces, and can thus participate in the event mechanism are: Component, RequestCycle, Session, and Application.

The mechanism allows for different event broadcast methods defined here:

Code Block



/**
 * Defines the event broadcast type.
 * 
 * @author igor
 */
public enum Broadcast {
	/**
	 * Breadth first traversal. Supported sinks in order of traversal:
	 * 
	 * <ol>
	 * <li>{@link Application}</li>
	 * <li>{@link Session}</li>
	 * <li>{@link RequestCycle}</li>
	 * <li>{@link Page}</li>
	 * <li>{@link Component}s</li>
	 * </ol>
	 * 
	 * Any sink along the path can be specified and traversal will start with the specified sink as
	 * root, eg:
	 * 
	 * <ul>
	 * <li>If a component inside the page is specified then only the component and all its children
	 * will receive the event</li>
	 * <li>If Session is specified then the session, the request cycle, the page and all its
	 * components will receive the event</li>
	 * </ul>
	 */
	BREADTH,
	/**
	 * Depth first traversal. Supported sinks in order of traversal:
	 * 
	 * <ol>
	 * <li>{@link Component}s</li>
	 * <li>{@link Page}</li>
	 * <li>{@link RequestCycle}</li>
	 * <li>{@link Session}</li>
	 * <li>{@link Application}</li>
	 * </ol>
	 * 
	 * Any sink along the path can be specified and traversal will start with the specified sink as
	 * root, eg:
	 * 
	 * <ul>
	 * <li>If a component inside the page is specified then only the component and all its children
	 * will receive the event</li>
	 * <li>If Session is specified then the session, the request cycle, the page and all its
	 * components will receive the event</li>
	 * </ul>
	 * 
	 */
	DEPTH,
	/**
	 * A bubble-up traversal. In a bubble-up traversal only the sink and its parents are notified.
	 * 
	 * Supported sinks in order of traversal are:
	 * <ol>
	 * <li>{@link Component}s</li>
	 * <li>{@link Page}</li>
	 * <li>{@link RequestCycle}</li>
	 * <li>{@link Session}</li>
	 * <li>{@link Application}</li>
	 * </ol>
	 * 
	 * Any sink along the path can be specified and traversal will start at the specified sink and
	 * work its way up to the {@link Application}, eg:
	 * 
	 * <ul>
	 * <li>If a component inside the page is specified then only the component, its parents, the
	 * request cycle, the session, and the application will be notified.
	 * <li>If Session is specified then the session, the application will be notified</li>
	 * </ul>
	 */
	BUBBLE,
	/**
	 * Only the specified sink receives the event
	 */
	EXACT;
}

There is an example in wicket-examples which demonstrates the usage of this.

List of renamed classes and methods

...