org.apache.wicket.version
Interface IPageVersionManager

All Superinterfaces:
IClusterable, java.io.Serializable
All Known Implementing Classes:
UndoPageVersionManager

public interface IPageVersionManager
extends IClusterable

An interface that manages versions of a Page. Initially a page has a version number of 0, indicating that it is in its original state. When one or more changes are made to the page, we arrive at version 1.

During a RequestCycle, just before a change is about to occur, the beginVersion method is called, followed by one or more calls to componentAdded, componentRemoved or componentModelChanging. If beginVersion is called by the framework during a given request cycle, a balancing call to endVersion will occur at the end of the request cycle. However, if no changes occur to a page during a request cycle, none of these methods will be called.

Once version information has been added to a page version manager (IPageVersionManager), versions can be retrieved by number using the getVersion(int) method. Since version 0 is the first version of a page, calling getVersion(0) will retrieve that version.

The current version number of a page (that is, the number of the newest available version) can be retrieved by calling getCurrentVersionNumber.

Since:
1.2.6
Author:
Jonathan Locke

Method Summary
 void beginVersion(boolean mergeVersion)
          Called when changes are immediately impending to the Page being managed.
 void componentAdded(Component component)
          Indicates that the given Component was added.
 void componentModelChanging(Component component)
          Indicates that the model for the given Component is about to change.
 void componentRemoved(Component component)
          Indicates that the given Component was removed.
 void componentStateChanging(Change change)
          Indicates an internal state for the given Component is about to change.
 void endVersion(boolean mergeVersion)
          Called when changes to the Page have ended.
 void expireOldestVersion()
          Expires oldest version in this page version manager.
 int getAjaxVersionNumber()
          Retrieves the current Ajax version number.
 int getCurrentVersionNumber()
          Retrieves the newest version number available in this page version manager.
 Page getVersion(int versionNumber)
          Retrieves a given Page version.
 int getVersions()
          Retrieves the number of versions stored in this page version manager.
 void ignoreVersionMerge()
          Call this method if the current Ajax request shouldn't merge changes that are happening to the Page with the previous version.
 Page rollbackPage(int numberOfVersions)
          Rolls back the Page by the number of versions specified, including the Ajax versions.
 

Method Detail

beginVersion

void beginVersion(boolean mergeVersion)
Called when changes are immediately impending to the Page being managed. The changes to the page between the call to this method and the call to endVersion create a new version of the page.

In requests where a page is not changed at all, beginVersion will never be called, nor will any of the other methods in this interface.

Parameters:
mergeVersion - If this is set, the version that was created is merged with the previous one.

componentAdded

void componentAdded(Component component)
Indicates that the given Component was added.

Parameters:
component - the Component that was added

componentModelChanging

void componentModelChanging(Component component)
Indicates that the model for the given Component is about to change.

Parameters:
component - the Component whose model is about to change

componentStateChanging

void componentStateChanging(Change change)
Indicates an internal state for the given Component is about to change.

Parameters:
change - the Change which represents the internal state

componentRemoved

void componentRemoved(Component component)
Indicates that the given Component was removed.

Parameters:
component - the Component that was removed

endVersion

void endVersion(boolean mergeVersion)
Called when changes to the Page have ended.

Parameters:
mergeVersion - If this is set, the version that was created is merged with the previous one.
See Also:
beginVersion(boolean)

expireOldestVersion

void expireOldestVersion()
Expires oldest version in this page version manager.


getVersion

Page getVersion(int versionNumber)
Retrieves a given Page version. This method does not include the Ajax versions.

Parameters:
versionNumber - the version of the page to get
Returns:
the Page, or null if the version requested is not available

rollbackPage

Page rollbackPage(int numberOfVersions)
Rolls back the Page by the number of versions specified, including the Ajax versions.

Parameters:
numberOfVersions - the number of versions to roll back
Returns:
the rolled-back Page

getVersions

int getVersions()
Retrieves the number of versions stored in this page version manager.

Returns:
the number of versions stored in this IPageVersionManager

getCurrentVersionNumber

int getCurrentVersionNumber()
Retrieves the newest version number available in this page version manager.

Returns:
the current (newest) version number available in this IPageVersionManager

getAjaxVersionNumber

int getAjaxVersionNumber()
Retrieves the current Ajax version number.

Returns:
the current Ajax version number.

ignoreVersionMerge

void ignoreVersionMerge()
Call this method if the current Ajax request shouldn't merge changes that are happening to the Page with the previous version. This is needed, for example, when you want to redirect to this page in an Ajax request, and then you want to version normally.

This method should only be called if the beginVersion method was called with true!

See Also:
beginVersion(boolean)


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.