Package org.apache.tapestry5.internal.services

## 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 java.lang.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​(java.lang.String prefix, Request request)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.Object` | `convertApplicationValueToPersisted​(java.lang.Object newValue)` | Hook that allows a value to be converted as it is written to the session.
    `java.lang.Object` | `convertPersistedToApplicationValue​(java.lang.Object persistedValue)` | Converts a persisted value stored in the session back into an application value.
    `protected void` | `didReadChange​(Session session, java.lang.String attributeName)` | Called after each key is read by `gatherFieldChanges(String)`.
    `void` | `discardChanges​(java.lang.String pageName)` | Discards any saved changes for the name page.
    `java.util.Collection<PersistentFieldChange>` | `gatherFieldChanges​(java.lang.String pageName)` | Finds all persistent changes previously stored for the named page (for the current active session or client).
    `void` | `postChange​(java.lang.String pageName, java.lang.String componentId, java.lang.String fieldName, java.lang.Object newValue)` | Posts a change of a persistent property.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractSessionPersistentFieldStrategy

          protected AbstractSessionPersistentFieldStrategy​(java.lang.String prefix,
                                                           Request request)

  - ### Method Detail

    - #### gatherFieldChanges

          public final java.util.Collection<PersistentFieldChange> gatherFieldChanges​(java.lang.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 interface `PersistentFieldStrategy`

    - #### discardChanges

          public void discardChanges​(java.lang.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 interface `PersistentFieldStrategy`
      Parameters:
        `pageName` - logical name of page whose field persistent data should be discarded

    - #### didReadChange

          protected void didReadChange​(Session session,
                                       java.lang.String attributeName)

      Called after each key is read by `gatherFieldChanges(String)`. This implementation does nothing, subclasses may override.
      Parameters:
        `session` - the session from which a value was just read
        `attributeName` - the name of the attribute used to read a value

    - #### postChange

          public final void postChange​(java.lang.String pageName,
                                       java.lang.String componentId,
                                       java.lang.String fieldName,
                                       java.lang.Object newValue)

      Description copied from interface: `PersistentFieldStrategy`
      Posts a change of a persistent property.
      Specified by:
        `postChange` in interface `PersistentFieldStrategy`
      Parameters:
        `pageName` - the name of the page containing the component
        `componentId` - 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 changed
        `newValue` - the new value for the field, possibly null

    - #### convertApplicationValueToPersisted

          public java.lang.Object convertApplicationValueToPersisted​(java.lang.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 java.lang.Object convertPersistedToApplicationValue​(java.lang.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)`