Class PageProvider

  • All Implemented Interfaces:
    Serializable, IPageProvider, org.apache.wicket.util.io.IClusterable
    Direct Known Subclasses:
    PageAndComponentProvider

    public class PageProvider
    extends Object
    implements IPageProvider, org.apache.wicket.util.io.IClusterable
    Provides page instance for request handlers. Each of the constructors has just enough information to get existing or create new page instance. Requesting or creating page instance is deferred until getPageInstance() is called.

    Purpose of this class is to reduce complexity of both IRequestMappers and IRequestHandlers. IRequestMapper examines the URL, gathers all relevant information about the page in the URL (combination of page id, page class, page parameters and render count), creates PageProvider object and creates a IRequestHandler instance that can use the PageProvider to access the page.

    Apart from simplifying IRequestMappers and IRequestHandlers PageProvider also helps performance because creating or obtaining page from IPageManager is delayed until the IRequestHandler actually requires the page.

    Author:
    Matej Knopp
    See Also:
    Serialized Form
    • Constructor Detail

      • PageProvider

        public PageProvider​(Integer pageId,
                            Integer renderCount)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return page instance with specified id.
        Parameters:
        pageId -
        renderCount - optional argument
      • PageProvider

        public PageProvider​(Integer pageId,
                            Class<? extends IRequestablePage> pageClass,
                            Integer renderCount)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return page instance with specified id if it exists and it's class matches pageClass. If none of these is true new page instance will be created.
        Parameters:
        pageId -
        pageClass -
        renderCount - optional argument
      • PageProvider

        public PageProvider​(Integer pageId,
                            Class<? extends IRequestablePage> pageClass,
                            org.apache.wicket.request.mapper.parameter.PageParameters pageParameters,
                            Integer renderCount)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return page instance with specified id if it exists and it's class matches pageClass. If none of these is true new page instance will be created.
        Parameters:
        pageId -
        pageClass -
        pageParameters -
        renderCount - optional argument
      • PageProvider

        public PageProvider​(Class<? extends IRequestablePage> pageClass,
                            org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return new instance of page with specified class.
        Parameters:
        pageClass -
        pageParameters -
      • PageProvider

        public PageProvider​(Class<? extends IRequestablePage> pageClass)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return new instance of page with specified class.
        Parameters:
        pageClass -
      • PageProvider

        public PageProvider​(IRequestablePage page)
        Creates a new page provider object. Upon calling of getPageInstance() this provider will return the given page instance.
        Parameters:
        page -
    • Method Detail

      • getPageParameters

        public org.apache.wicket.request.mapper.parameter.PageParameters getPageParameters()
                                                                                    throws PageExpiredException
        Description copied from interface: IPageProvider
        Returns PageParameters of the page.
        Specified by:
        getPageParameters in interface IPageProvider
        Returns:
        page parameters
        Throws:
        PageExpiredException - if the specified page could not have been found and the constructor used did not provide enough information to create new page instance
      • hasPageInstance

        public final boolean hasPageInstance()
        If this provider returns existing page, regardless if it was already created by PageProvider itself or is or can be found in the data store. The only guarantee is that by calling getPageInstance() this provider will return an existing instance and no page will be created.
        Specified by:
        hasPageInstance in interface IPageProvider
        Returns:
        if provides an existing page
      • doesProvideNewPage

        public final boolean doesProvideNewPage()
        Returns whether or not the page instance held by this provider has been instantiated by the provider.
        Specified by:
        doesProvideNewPage in interface IPageProvider
        Returns:
        true iff the page instance held by this provider was instantiated by the provider
      • wasExpired

        public boolean wasExpired()
        Description copied from interface: IPageProvider
        Returns whether the provided page was expired prior to this access.
        Specified by:
        wasExpired in interface IPageProvider
        Returns:
        true> if the page was created after its original instance expired.
      • getPageSource

        protected IPageSource getPageSource()
      • setPageSource

        public void setPageSource​(IPageSource pageSource)
        If the PageProvider is used outside request thread (thread that does not have application instance assigned) it is necessary to specify a IPageSource instance so that PageProvider knows how to get a page instance.
        Parameters:
        pageSource -
      • setPageParameters

        protected void setPageParameters​(org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)
        Parameters:
        pageParameters -
      • getRenderCount

        public Integer getRenderCount()
        Description copied from interface: IPageProvider
        Returns the number of times this page has been rendered.
        Specified by:
        getRenderCount in interface IPageProvider
        Returns:
        the number of times this page has been rendered.