Interface Page

  • All Superinterfaces:
    PageLifecycleCallbackHub
    All Known Implementing Classes:
    PageImpl

    public interface Page
    extends PageLifecycleCallbackHub
    Represents a unique page within the application. Pages are part of the internal structure of a Tapestry application; end developers who refer to "page" are really referring to the root component of the actual page. Starting in release 5.2, the nature of pages changed considerably. Pages are no longer pooled instances. Instead, pages are shared instances (per locale) but all internal mutable state is stored inside PerthreadManager. Page construction time is considered to extend past the page loaded callback. This is not quite perfect from a threading point-of-view (arguably, even write-once-read-many fields should be protected by synchronized blocks or other mechanisms). At best, we can be assured that the entire page construction phase is protected by a single synchronized block (but not on the page itself). An ideal system would build the page bottom to top so that all assignments could take place in constructors, assigning to final fields. Maybe some day. The Page object is never visible to end-user code, though it exposes an interface (PageLifecycleCallbackHub that is).
    • Method Detail

      • getName

         getName()
        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).
      • setRootElement

        void setRootElement​(ComponentPageElement component)
        Invoked during page construction time to connect the page's root component to the page instance.
      • getRootComponent

        Component getRootComponent()
        The root component of the page. A convenience over invoking getRootElement().getComponent().
      • detached

        boolean detached()
        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.
        Returns:
        true if the page is "dirty", false otherwise
        See Also:
        PageLifecycleListener.containingPageDidDetach()
      • getLogger

        org.slf4j.Logger getLogger()
        Returns the logger of the root component element. Any logging about page construction or activity should be sent to this logger.
      • getComponentElementByNestedId

         nestedId)
        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.
        Throws:
        UnknownValueException - if the nestedId does not correspond to a component
      • persistFieldChange

        void persistFieldChange​(ComponentResources resources,
                                 fieldName,
                                 newValue)
        Posts a change to a persistent field.
        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

          nestedId,
                               fieldName)
        Gets a change for a field within the component.
        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

        void discardPersistentFieldChanges()
        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).
      • addResetListener

        void addResetListener​(PageResetListener listener)
        Deprecated.
        in 5.3.4,
        Adds a new listener for page reset events.
        Parameters:
        listener - will receive notifications when the page is accessed from a different page
        Since:
        5.2.0
      • setStats

        void setStats​(Page.Stats stats)
        Invoked once at the end of page construction, to provide page construction statistics.
        Since:
        5.3
      • getAttachCount

        int getAttachCount()
        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.
        Since:
        5.3