Class AbstractSessionPersistentFieldStrategy
- java.lang.Object
-
- org.apache.tapestry5.internal.services.AbstractSessionPersistentFieldStrategy
-
- All Implemented Interfaces:
PersistentFieldStrategy
- Direct Known Subclasses:
EntityPersistentFieldStrategy
,EntityPersistentFieldStrategy
,FlashPersistentFieldStrategy
,SessionPersistentFieldStrategy
public abstract class AbstractSessionPersistentFieldStrategy extends Object implements PersistentFieldStrategy
Base class for strategies that store their values as keys in the session. Implements a uniform format for the keys, based on a prefix to identify the particular strategy.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSessionPersistentFieldStrategy(String prefix, Request request)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
convertApplicationValueToPersisted(Object newValue)
Hook that allows a value to be converted as it is written to the session.Object
convertPersistedToApplicationValue(Object persistedValue)
Converts a persisted value stored in the session back into an application value.protected void
didReadChange(Session session, String attributeName)
Called after each key is read bygatherFieldChanges(String)
.void
discardChanges(String pageName)
Discards any saved changes for the name page.Collection<PersistentFieldChange>
gatherFieldChanges(String pageName)
Finds all persistent changes previously stored for the named page (for the current active session or client).void
postChange(String pageName, String componentId, String fieldName, Object newValue)
Posts a change of a persistent property.
-
-
-
Constructor Detail
-
AbstractSessionPersistentFieldStrategy
protected AbstractSessionPersistentFieldStrategy(String prefix, Request request)
-
-
Method Detail
-
gatherFieldChanges
public final Collection<PersistentFieldChange> gatherFieldChanges(String pageName)
Description copied from interface:PersistentFieldStrategy
Finds all persistent changes previously stored for the named page (for the current active session or client).- Specified by:
gatherFieldChanges
in interfacePersistentFieldStrategy
-
discardChanges
public void discardChanges(String pageName)
Description copied from interface:PersistentFieldStrategy
Discards any saved changes for the name page. There is no expectation that data already gathered from the strategy and presumably dumped into component instance fields will be affected, but future field access (within this request or a later one) will show no data for the indicated page.- Specified by:
discardChanges
in interfacePersistentFieldStrategy
- Parameters:
pageName
- logical name of page whose field persistent data should be discarded
-
didReadChange
protected void didReadChange(Session session, String attributeName)
Called after each key is read bygatherFieldChanges(String)
. This implementation does nothing, subclasses may override.- Parameters:
session
- the session from which a value was just readattributeName
- the name of the attribute used to read a value
-
postChange
public final void postChange(String pageName, String componentId, String fieldName, Object newValue)
Description copied from interface:PersistentFieldStrategy
Posts a change of a persistent property.- Specified by:
postChange
in interfacePersistentFieldStrategy
- Parameters:
pageName
- the name of the page containing the componentcomponentId
- the nested id path of the component (or null for the page's root component)fieldName
- the name of the field whose persistent value has changednewValue
- the new value for the field, possibly null
-
convertApplicationValueToPersisted
public Object convertApplicationValueToPersisted(Object newValue)
Hook that allows a value to be converted as it is written to the session. Passed the new value provided by the application, returns the object to be stored in the session. This implementation simply returns the provided value.- Parameters:
newValue
- non-null value- Returns:
- persisted value
- See Also:
convertPersistedToApplicationValue(Object)
-
convertPersistedToApplicationValue
public Object convertPersistedToApplicationValue(Object persistedValue)
Converts a persisted value stored in the session back into an application value. This implementation returns the persisted value as is.- Parameters:
persistedValue
- non-null persisted value- Returns:
- application value
- See Also:
convertPersistedToApplicationValue(Object)
-
-