|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.tapestry.record.PageRecorder
Tracks changes to components on a page, allowing changes to be persisted across request cycles, and restoring the state of a page and component when needed.
This is an abstract implementation; specific implementations can choose where and how to persist the data.
Implements Externalizable
but does not have any state of its own.
Subclasses must implement readExternal()
and
writeExternal()
.
Field Summary | |
protected boolean |
dirty
|
protected boolean |
locked
|
Constructor Summary | |
PageRecorder()
|
Method Summary | |
abstract void |
commit()
Invoked to persist all changes that have been accumulated. |
abstract java.util.Collection |
getChanges()
Returns a Collection of IPageChange objects
identifying changes to the page and its components. |
boolean |
isDirty()
Returns true if the page has observed a change. |
boolean |
isLocked()
Returns true if the recorder is locked. |
void |
observeChange(ObservedChangeEvent event)
Observes the change. |
protected java.io.Serializable |
persistValue(java.lang.Object value)
Invoked by subclasses to converts an object into a Serializable value for for persistent storage. |
protected abstract void |
recordChange(java.lang.String componentPath,
java.lang.String propertyName,
java.lang.Object newValue)
Records a change to a particular component. |
protected java.lang.Object |
restoreValue(java.lang.Object value)
Invoked by subclasses to restore a persisted value to its runtime value. |
void |
rollback(IPage page)
Rolls back the page to the currently persisted state. |
void |
setLocked(boolean value)
Invoked to lock or unlock the recorder. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.primix.tapestry.IPageRecorder |
getHasChanges |
Field Detail |
protected transient boolean dirty
protected transient boolean locked
Constructor Detail |
public PageRecorder()
Method Detail |
public abstract void commit() throws PageRecorderCommitException
Subclasses should check the dirty flag. If the recorder is dirty, changes should be recorded and the dirty flag cleared.
commit
in interface IPageRecorder
public abstract java.util.Collection getChanges()
Collection
of IPageChange
objects
identifying changes to the page and its components.getChanges
in interface IPageRecorder
public boolean isDirty()
commit()
.isDirty
in interface IPageRecorder
public boolean isLocked()
commit()
.isLocked
in interface IPageRecorder
public void setLocked(boolean value)
IPageRecorder
setLocked
in interface IPageRecorder
public void observeChange(ObservedChangeEvent event)
IComponent
. Ignores the change if not active,
otherwise, sets invokes recordChange(String, String,
Object)
.
If the property name in the event is null, then the recorder
is marked dirty (but
recordChange(String, String,
Object)
is not invoked. This is how a "distant" property changes
are propogated to the page recorder (a distant property change is a change to
a property of an object that is itself a property of the page).
If the recorder is not active (typically, when a page is being rewound), then the event is simply ignored.
observeChange
in interface ChangeObserver
protected abstract void recordChange(java.lang.String componentPath, java.lang.String propertyName, java.lang.Object newValue)
This method is responsible for setting the dirty flag if the described change is real.
componentPath
- the name of the component relative to the
page which contains it. May be null if the change was to a
property of the page itself.propertyName
- the name of the property which changed.newValue
- the new value for the property, which may also
be null.IComponent.getIdPath()
public void rollback(IPage page)
rollback
in interface IPageRecorder
protected java.io.Serializable persistValue(java.lang.Object value) throws java.io.IOException
Serializable
value for for persistent storage.
This implementation implements a special case
for converting an EJBObject
into a Handle
for storage.
protected java.lang.Object restoreValue(java.lang.Object value) throws java.io.IOException
Handle
s, stored
persistently, back into EJBObject
s.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |