Package org.apache.tapestry5.internal.structure

## Class PageImpl

- java.lang.Object
- - org.apache.tapestry5.internal.structure.PageImpl

- All Implemented Interfaces:
    `Page`, `PageLifecycleCallbackHub`

      public class PageImpl
      extends java.lang.Object
      implements Page

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tapestry5.internal.structure.Page

      `Page.Stats`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PageImpl​(java.lang.String name, ComponentResourceSelector selector, PersistentFieldManager persistentFieldManager, PerthreadManager perThreadManager, MetaDataLocator metaDataLocator)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addLifecycleListener​(PageLifecycleListener listener)` | Adds a listener that is notified of large scale page events.
    `void` | `addPageAttachedCallback​(java.lang.Runnable callback)` | Adds a callback for when the page is attached to the request.
    `void` | `addPageDetachedCallback​(java.lang.Runnable callback)` | Adds a callback for when the page is detached from the request.
    `void` | `addPageLoadedCallback​(java.lang.Runnable callback)` | Adds a callback for when the page is first loaded.
    `void` | `addResetCallback​(java.lang.Runnable callback)` | A reset occurs when a request for a page arrives that did not originate on the same page.
    `void` | `addResetListener​(PageResetListener listener)` | Adds a new listener for page reset events.
    `void` | `addVerifyCallback​(java.lang.Runnable callback)` | Adds a verify callback, which is allowed while the page is loading.
    `void` | `attached()` | Invoked to inform the page that it is attached to the current request.
    `boolean` | `detached()` | Invoked to inform the page that it is being detached from the current request.
    `void` | `discardPersistentFieldChanges()` | Discards all persistent field changes for the page containing the component.
    `int` | `getAttachCount()` | Returns the number of times the page has been attached to a request.
    `ComponentPageElement` | `getComponentElementByNestedId​(java.lang.String nestedId)` | Retrieves a component element by its nested id (a sequence of simple ids, separated by dots).
    `java.lang.Object` | `getFieldChange​(java.lang.String nestedId, java.lang.String fieldName)` | Gets a change for a field within the component.
    `org.slf4j.Logger` | `getLogger()` | Returns the logger of the root component element.
    `java.lang.String` | `getName()` | Returns the short, logical name for the page.
    `Component` | `getRootComponent()` | The root component of the page.
    `ComponentPageElement` | `getRootElement()` | The root component of the page.
    `ComponentResourceSelector` | `getSelector()` | The selector (which includes Locale) used when the page was constructor.
    `Page.Stats` | `getStats()` | Returns the page construction statistics for this page.
    `boolean` | `hasResetListeners()` | Returns true if there are any `PageResetListener` listeners.
    `boolean` | `isExactParameterCountMatch()` | Returns true if extract parameter count matching is enabled.
    `void` | `loaded()` | Inform the page that it is now completely loaded.
    `void` | `pageReset()` | Invoked to notify `PageResetListener` listeners.
    `void` | `persistFieldChange​(ComponentResources resources, java.lang.String fieldName, java.lang.Object newValue)` | Posts a change to a persistent field.
    `void` | `removeLifecycleListener​(PageLifecycleListener listener)` | Removes a listener that was previously added.
    `void` | `setRootElement​(ComponentPageElement component)` | Invoked during page construction time to connect the page's root component to the page instance.
    `void` | `setStats​(Page.Stats stats)` | Invoked once at the end of page construction, to provide page construction statistics.
    `java.lang.String` | `toString()` |

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

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

- - ### Constructor Detail

    - #### PageImpl

          public PageImpl​(java.lang.String name,
                          ComponentResourceSelector selector,
                          PersistentFieldManager persistentFieldManager,
                          PerthreadManager perThreadManager,
                          MetaDataLocator metaDataLocator)

      Parameters:
        `name` - canonicalized page name
        `selector` - used to locate resources
        `persistentFieldManager` - for access to cross-request persistent values
        `perThreadManager` -
        `metaDataLocator` -

  - ### Method Detail

    - #### setStats

          public void setStats​(Page.Stats stats)

      Description copied from interface: `Page`
      Invoked once at the end of page construction, to provide page construction statistics.
      Specified by:
        `setStats` in interface `Page`

    - #### getStats

          public Page.Stats getStats()

      Description copied from interface: `Page`
      Returns the page construction statistics for this page.
      Specified by:
        `getStats` in interface `Page`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getComponentElementByNestedId

          public ComponentPageElement getComponentElementByNestedId​(java.lang.String nestedId)

      Description copied from interface: `Page`
      Retrieves a component element by its nested id (a sequence of simple ids, separated by dots). The individual names in the nested id are matched without regards to case. A nested id of '' (the empty string) returns the root element of the page.
      Specified by:
        `getComponentElementByNestedId` in interface `Page`

    - #### getSelector

          public ComponentResourceSelector getSelector()

      Description copied from interface: `Page`
      The selector (which includes Locale) used when the page was constructor.
      Specified by:
        `getSelector` in interface `Page`

    - #### setRootElement

          public void setRootElement​(ComponentPageElement component)

      Description copied from interface: `Page`
      Invoked during page construction time to connect the page's root component to the page instance.
      Specified by:
        `setRootElement` in interface `Page`

    - #### getRootElement

          public ComponentPageElement getRootElement()

      Description copied from interface: `Page`
      The root component of the page. This is the wrapper around the end developer's view of the page.
      Specified by:
        `getRootElement` in interface `Page`

    - #### getRootComponent

          public Component getRootComponent()

      Description copied from interface: `Page`
      The root component of the page. A convenience over invoking getRootElement().getComponent().
      Specified by:
        `getRootComponent` in interface `Page`

    - #### addLifecycleListener

          public void addLifecycleListener​(PageLifecycleListener listener)

      Description copied from interface: `Page`
      Adds a listener that is notified of large scale page events.
      Specified by:
        `addLifecycleListener` in interface `Page`

    - #### removeLifecycleListener

          public void removeLifecycleListener​(PageLifecycleListener listener)

      Description copied from interface: `Page`
      Removes a listener that was previously added.
      Specified by:
        `removeLifecycleListener` in interface `Page`

    - #### detached

          public boolean detached()

      Description copied from interface: `Page`
      Invoked to inform the page that it is being detached from the current request. This occurs just before the page is returned to the page pool. A page may be clean or dirty. A page is dirty if its dirty count is greater than zero (meaning that, during the render of the page, some components did not fully render), or if any of its listeners throw an exception from containingPageDidDetach(). The page pool should discard pages that are dirty, rather than store them into the pool. Under Tapestry 5.2 and pool-less pages, the result is ignored; all mutable state is expected to be discarded automatically from the `PerthreadManager`. A future release of Tapestry will likely convert this method to type void.
      Specified by:
        `detached` in interface `Page`
      Returns:
        true if the page is "dirty", false otherwise
      See Also:
        `PageLifecycleListener.containingPageDidDetach()`

    - #### loaded

          public void loaded()

      Description copied from interface: `Page`
      Inform the page that it is now completely loaded.
      Specified by:
        `loaded` in interface `Page`
      See Also:
        `PageLifecycleListener.containingPageDidLoad()`

    - #### attached

          public void attached()

      Description copied from interface: `Page`
      Invoked to inform the page that it is attached to the current request. This occurs when a page is first referenced within a request. If the page was created from scratch for this request, the call to `Page.loaded()` will preceded the call to `Page.attached()`. First all listeners have `PageLifecycleListener.restoreStateBeforePageAttach()` invoked, followed by `PageLifecycleListener.containingPageDidAttach()`.
      Specified by:
        `attached` in interface `Page`

    - #### getLogger

          public org.slf4j.Logger getLogger()

      Description copied from interface: `Page`
      Returns the logger of the root component element. Any logging about page construction or activity should be sent to this logger.
      Specified by:
        `getLogger` in interface `Page`

    - #### persistFieldChange

          public void persistFieldChange​(ComponentResources resources,
                                         java.lang.String fieldName,
                                         java.lang.Object newValue)

      Description copied from interface: `Page`
      Posts a change to a persistent field.
      Specified by:
        `persistFieldChange` in interface `Page`
      Parameters:
        `resources` - the component resources for the component or mixin containing the field whose value changed
        `fieldName` - the name of the field
        `newValue` - the new value for the field

    - #### getFieldChange

          public java.lang.Object getFieldChange​(java.lang.String nestedId,
                                                 java.lang.String fieldName)

      Description copied from interface: `Page`
      Gets a change for a field within the component.
      Specified by:
        `getFieldChange` in interface `Page`
      Parameters:
        `nestedId` - the nested component id of the component containing the field
        `fieldName` - the name of the persistent field
      Returns:
        the value, or null if no value is stored

    - #### discardPersistentFieldChanges

          public void discardPersistentFieldChanges()

      Description copied from interface: `Page`
      Discards all persistent field changes for the page containing the component. Changes are eliminated from persistent storage (such as the `Session`) which will take effect in the next request (the attached page instance is not affected).
      Specified by:
        `discardPersistentFieldChanges` in interface `Page`

    - #### getName

          public java.lang.String getName()

      Description copied from interface: `Page`
      Returns the short, logical name for the page. This is the page name as it might included in an action or page render URL (though it will be converted to lower case when it is included).
      Specified by:
        `getName` in interface `Page`

    - #### addResetCallback

          public void addResetCallback​(java.lang.Runnable callback)

      Description copied from interface: `PageLifecycleCallbackHub`
      A reset occurs when a request for a page arrives that did not originate on the same page. This gives the application a chance to reset the state of the page.
      Specified by:
        `addResetCallback` in interface `PageLifecycleCallbackHub`
      Parameters:
        `callback` - invoked when a page is activated by link from some other page.

    - #### addResetListener

          public void addResetListener​(PageResetListener listener)

      Description copied from interface: `Page`
      Adds a new listener for page reset events.
      Specified by:
        `addResetListener` in interface `Page`
      Parameters:
        `listener` - will receive notifications when the page is accessed from a different page

    - #### addVerifyCallback

          public void addVerifyCallback​(java.lang.Runnable callback)

      Description copied from interface: `PageLifecycleCallbackHub`
      Adds a verify callback, which is allowed while the page is loading. Such callbacks are invoked once, after the page has been loaded successfully, and are then discarded. This was added specifically to ensure that components only verify that required parameters are bound after all components and mixins of the page have had a chance to initialize.
      Specified by:
        `addVerifyCallback` in interface `PageLifecycleCallbackHub`
      Parameters:
        `callback` - to be invoked after page loaded

    - #### pageReset

          public void pageReset()

      Description copied from interface: `Page`
      Invoked to notify `PageResetListener` listeners.
      Specified by:
        `pageReset` in interface `Page`

    - #### hasResetListeners

          public boolean hasResetListeners()

      Description copied from interface: `Page`
      Returns true if there are any `PageResetListener` listeners.
      Specified by:
        `hasResetListeners` in interface `Page`

    - #### getAttachCount

          public int getAttachCount()

      Description copied from interface: `Page`
      Returns the number of times the page has been attached to a request. This is a rough measure of how important the page is, relative to other pages. This value is volatile, changing constantly.
      Specified by:
        `getAttachCount` in interface `Page`

    - #### isExactParameterCountMatch

          public boolean isExactParameterCountMatch()

      Description copied from interface: `Page`
      Returns true if extract parameter count matching is enabled.
      Specified by:
        `isExactParameterCountMatch` in interface `Page`
      See Also:
        `MetaDataConstants.UNKNOWN_ACTIVATION_CONTEXT_CHECK`

    - #### addPageLoadedCallback

          public void addPageLoadedCallback​(java.lang.Runnable callback)

      Description copied from interface: `PageLifecycleCallbackHub`
      Adds a callback for when the page is first loaded. Callbacks are invoked in the order they are added to the page. They are invoked once and then discarded.
      Specified by:
        `addPageLoadedCallback` in interface `PageLifecycleCallbackHub`
      Parameters:
        `callback` - invoked once, when page is first loaded

    - #### addPageAttachedCallback

          public void addPageAttachedCallback​(java.lang.Runnable callback)

      Description copied from interface: `PageLifecycleCallbackHub`
      Adds a callback for when the page is attached to the request.
      Specified by:
        `addPageAttachedCallback` in interface `PageLifecycleCallbackHub`

    - #### addPageDetachedCallback

          public void addPageDetachedCallback​(java.lang.Runnable callback)

      Description copied from interface: `PageLifecycleCallbackHub`
      Adds a callback for when the page is detached from the request.
      Specified by:
        `addPageDetachedCallback` in interface `PageLifecycleCallbackHub`