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 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 and Description
    --- | ---
    `protected` | `AbstractSessionPersistentFieldStrategy(String prefix, Request request)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `convertApplicationValueToPersisted(Object newValue)` Hook that allows a value to be converted as it is written to the session.
    `protected 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 by `gatherFieldChanges(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.

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

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

- - ### 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 interface `PersistentFieldStrategy`

    - #### 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 interface `PersistentFieldStrategy`
      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 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(String pageName,
                                       String componentId,
                                       String fieldName,
                                       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

          protected 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

          protected 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)`

5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.