org.apache.wicket.version
Interface IPageVersionManager

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

public interface IPageVersionManager
extends IClusterable

Interface to code 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 request cycle, just before a change is about to occur, beginVersion() 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 endVersion() call 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 version manager, versions can be retrieved by number using getVersion(int). Since version 0 is the first version of a page, calling getVersion(0) will retrieve that version.

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

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
 int getAjaxVersionNumber()
           
 int getCurrentVersionNumber()
           
 Page getVersion(int versionNumber)
          Retrieves a given Page version.
 int getVersions()
           
 void ignoreVersionMerge()
          Call this method when the current (ajax) request shouldn't merge the changes that are happening to the page with the previous version.
 Page rollbackPage(int numberOfVersions)
          This method rollbacks the page 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:
IPageVersionManager#beginVersion()

expireOldestVersion

void expireOldestVersion()
Expires oldest version


getVersion

Page getVersion(int versionNumber)
Retrieves a given Page version. This method does not take use 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)
This method rollbacks the page the number of versions specified Including the ajax versions.

Parameters:
numberOfVersions -
Returns:

getVersions

int getVersions()
Returns:
The number of versions stored in this version manager

getCurrentVersionNumber

int getCurrentVersionNumber()
Returns:
Returns the current (newest) version number available through this version manager.

getAjaxVersionNumber

int getAjaxVersionNumber()
Returns:
Returns the current ajax version number.

ignoreVersionMerge

void ignoreVersionMerge()
Call this method when the current (ajax) request shouldn't merge the changes that are happening to the page with the previous version. This is for example needed when you want to redirect to this page in an ajax request and then you do want to version normally.. This method should only be called if the beginVersion was called with true!



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