org.apache.wicket.version.undo
Class UndoPageVersionManager

java.lang.Object
  extended by org.apache.wicket.version.undo.UndoPageVersionManager
All Implemented Interfaces:
java.io.Serializable, IClusterable, IPageVersionManager

public class UndoPageVersionManager
extends java.lang.Object
implements IPageVersionManager

A version manager implemented by recording Component changes as undo records. These records can later be reversed to get back to a given version of the Page being managed.

Since:
1.2.6
Author:
Jonathan Locke
See Also:
Serialized Form

Constructor Summary
UndoPageVersionManager(Page page, int maxVersions)
          Constructor.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UndoPageVersionManager

public UndoPageVersionManager(Page page,
                              int maxVersions)
Constructor.

Parameters:
page - the Page that we're tracking changes to
maxVersions - the maximum number of versions to maintain before expiring old versions
Method Detail

beginVersion

public void beginVersion(boolean mergeVersion)
Description copied from interface: IPageVersionManager
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.

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

ignoreVersionMerge

public void ignoreVersionMerge()
Description copied from interface: IPageVersionManager
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!

Specified by:
ignoreVersionMerge in interface IPageVersionManager
See Also:
IPageVersionManager.ignoreVersionMerge()

componentAdded

public void componentAdded(Component component)
Description copied from interface: IPageVersionManager
Indicates that the given Component was added.

Specified by:
componentAdded in interface IPageVersionManager
Parameters:
component - the Component that was added
See Also:
IPageVersionManager.componentAdded(Component)

componentModelChanging

public void componentModelChanging(Component component)
Description copied from interface: IPageVersionManager
Indicates that the model for the given Component is about to change.

Specified by:
componentModelChanging in interface IPageVersionManager
Parameters:
component - the Component whose model is about to change
See Also:
IPageVersionManager.componentModelChanging(Component)

componentRemoved

public void componentRemoved(Component component)
Description copied from interface: IPageVersionManager
Indicates that the given Component was removed.

Specified by:
componentRemoved in interface IPageVersionManager
Parameters:
component - the Component that was removed
See Also:
IPageVersionManager.componentRemoved(Component)

componentStateChanging

public void componentStateChanging(Change change)
Description copied from interface: IPageVersionManager
Indicates an internal state for the given Component is about to change.

Specified by:
componentStateChanging in interface IPageVersionManager
Parameters:
change - the Change which represents the internal state
See Also:
IPageVersionManager.componentStateChanging(Change)

endVersion

public void endVersion(boolean mergeVersion)
Description copied from interface: IPageVersionManager
Called when changes to the Page have ended.

Specified by:
endVersion in interface IPageVersionManager
Parameters:
mergeVersion - If this is set, the version that was created is merged with the previous one.
See Also:
IPageVersionManager.endVersion(boolean)

expireOldestVersion

public void expireOldestVersion()
Description copied from interface: IPageVersionManager
Expires oldest version in this page version manager.

Specified by:
expireOldestVersion in interface IPageVersionManager
See Also:
IPageVersionManager.expireOldestVersion()

getCurrentVersionNumber

public int getCurrentVersionNumber()
Description copied from interface: IPageVersionManager
Retrieves the newest version number available in this page version manager.

Specified by:
getCurrentVersionNumber in interface IPageVersionManager
Returns:
the current (newest) version number available in this IPageVersionManager
See Also:
IPageVersionManager.getCurrentVersionNumber()

getAjaxVersionNumber

public int getAjaxVersionNumber()
Description copied from interface: IPageVersionManager
Retrieves the current Ajax version number.

Specified by:
getAjaxVersionNumber in interface IPageVersionManager
Returns:
the current Ajax version number.
See Also:
IPageVersionManager.getAjaxVersionNumber()

getVersion

public Page getVersion(int versionNumber)
Description copied from interface: IPageVersionManager
Retrieves a given Page version. This method does not include the Ajax versions.

Specified by:
getVersion in interface IPageVersionManager
Parameters:
versionNumber - the version of the page to get
Returns:
the Page, or null if the version requested is not available
See Also:
IPageVersionManager.getVersion(int)

rollbackPage

public Page rollbackPage(int numberOfVersions)
Description copied from interface: IPageVersionManager
Rolls back the Page by the number of versions specified, including the Ajax versions.

Specified by:
rollbackPage in interface IPageVersionManager
Parameters:
numberOfVersions - the number of versions to roll back
Returns:
the rolled-back Page
See Also:
IPageVersionManager.rollbackPage(int)

getVersions

public int getVersions()
Description copied from interface: IPageVersionManager
Retrieves the number of versions stored in this page version manager.

Specified by:
getVersions in interface IPageVersionManager
Returns:
the number of versions stored in this IPageVersionManager
See Also:
IPageVersionManager.getVersions()


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