java.lang.Object
org.apache.wicket.core.request.handler.PageProvider
- All Implemented Interfaces:
Serializable
,IPageProvider
,IClusterable
- Direct Known Subclasses:
PageAndComponentProvider
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 IRequestMapper
s and
IRequestHandler
s. 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 IRequestMapper
s and IRequestHandler
s 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:
-
Constructor Summary
ConstructorDescriptionPageProvider
(Class<? extends IRequestablePage> pageClass) Creates a new page provider object.PageProvider
(Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) Creates a new page provider object.PageProvider
(Integer pageId, Class<? extends IRequestablePage> pageClass, Integer renderCount) Creates a new page provider object.PageProvider
(Integer pageId, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount) Creates a new page provider object.PageProvider
(Integer pageId, Integer renderCount) Creates a new page provider object.PageProvider
(IRequestablePage page) Creates a new page provider object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
detach()
Detaches the page if it has been loaded (that means eitherPageProvider(IRequestablePage)
constructor has been used orgetPageInstance()
has been called).final boolean
Returns whether or not the page instance held by this provider has been instantiated by the provider.Class<? extends IRequestablePage>
Returns class of the page.Returns the page id.Returns page instance specified by the constructor.ReturnsPageParameters
of the page.protected IPageSource
Returns the number of times this page has been rendered.final boolean
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.protected void
setPageParameters
(PageParameters pageParameters) void
setPageSource
(IPageSource pageSource) If thePageProvider
is used outside request thread (thread that does not have application instance assigned) it is necessary to specify aIPageSource
instance so thatPageProvider
knows how to get a page instance.toString()
boolean
Returns whether the provided page was expired prior to this access.
-
Constructor Details
-
PageProvider
Creates a new page provider object. Upon calling ofgetPageInstance()
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 ofgetPageInstance()
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, PageParameters pageParameters, Integer renderCount) Creates a new page provider object. Upon calling ofgetPageInstance()
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
Creates a new page provider object. Upon calling ofgetPageInstance()
this provider will return new instance of page with specified class.- Parameters:
pageClass
-pageParameters
-
-
PageProvider
Creates a new page provider object. Upon calling ofgetPageInstance()
this provider will return new instance of page with specified class.- Parameters:
pageClass
-
-
PageProvider
Creates a new page provider object. Upon calling ofgetPageInstance()
this provider will return the given page instance.- Parameters:
page
-
-
-
Method Details
-
getPageInstance
Description copied from interface:IPageProvider
Returns page instance specified by the constructor.- Specified by:
getPageInstance
in interfaceIPageProvider
- Returns:
- page instance
- 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
-
getPageParameters
Description copied from interface:IPageProvider
ReturnsPageParameters
of the page.- Specified by:
getPageParameters
in interfaceIPageProvider
- 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
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 callinggetPageInstance()
this provider will return an existing instance and no page will be created.- Specified by:
hasPageInstance
in interfaceIPageProvider
- Returns:
- if provides an existing page
-
doesProvideNewPage
Returns whether or not the page instance held by this provider has been instantiated by the provider.- Specified by:
doesProvideNewPage
in interfaceIPageProvider
- Returns:
true
iff the page instance held by this provider was instantiated by the provider
-
wasExpired
Description copied from interface:IPageProvider
Returns whether the provided page was expired prior to this access.- Specified by:
wasExpired
in interfaceIPageProvider
- Returns:
true
if the page was created after its original instance expired.
-
getPageClass
Description copied from interface:IPageProvider
Returns class of the page.- Specified by:
getPageClass
in interfaceIPageProvider
- Returns:
- page class
- 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
-
getPageSource
-
detach
Detaches the page if it has been loaded (that means eitherPageProvider(IRequestablePage)
constructor has been used orgetPageInstance()
has been called).- Specified by:
detach
in interfaceIPageProvider
-
setPageSource
If thePageProvider
is used outside request thread (thread that does not have application instance assigned) it is necessary to specify aIPageSource
instance so thatPageProvider
knows how to get a page instance.- Parameters:
pageSource
-
-
setPageParameters
- Parameters:
pageParameters
-
-
getPageId
Description copied from interface:IPageProvider
Returns the page id.- Specified by:
getPageId
in interfaceIPageProvider
- Returns:
- page id
-
getRenderCount
Description copied from interface:IPageProvider
Returns the number of times this page has been rendered.- Specified by:
getRenderCount
in interfaceIPageProvider
- Returns:
- the number of times this page has been rendered.
-
toString
-