public class PageProvider extends Object implements IPageProvider, org.apache.wicket.util.io.IClusterable
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.
Constructor and Description |
---|
PageProvider(Class<? extends IRequestablePage> pageClass)
Creates a new page provider object.
|
PageProvider(Class<? extends IRequestablePage> pageClass,
org.apache.wicket.request.mapper.parameter.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,
org.apache.wicket.request.mapper.parameter.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.
|
Modifier and Type | Method and Description |
---|---|
void |
detach()
Detaches the page if it has been loaded (that means either
PageProvider(IRequestablePage) constructor has been used or
getPageInstance() has been called). |
boolean |
doesProvideNewPage()
Returns whether or not the page instance held by this provider has been instantiated by the
provider.
|
Class<? extends IRequestablePage> |
getPageClass()
Returns class of the page.
|
Integer |
getPageId()
Returns the page id.
|
IRequestablePage |
getPageInstance()
Returns page instance specified by the constructor.
|
org.apache.wicket.request.mapper.parameter.PageParameters |
getPageParameters()
Returns
PageParameters of the page. |
protected IPageSource |
getPageSource() |
Integer |
getRenderCount()
Returns the number of times this page has been rendered.
|
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.
|
boolean |
isNewPageInstance()
Deprecated.
use
hasPageInstance() negation instead |
protected void |
setPageParameters(org.apache.wicket.request.mapper.parameter.PageParameters pageParameters) |
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. |
String |
toString() |
boolean |
wasExpired()
Returns whether the provided page was expired prior to this access.
|
public PageProvider(Integer pageId, Integer renderCount)
getPageInstance()
this provider
will return page instance with specified id.pageId
- renderCount
- optional argumentpublic PageProvider(Integer pageId, Class<? extends IRequestablePage> pageClass, Integer renderCount)
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.pageId
- pageClass
- renderCount
- optional argumentpublic PageProvider(Integer pageId, Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, Integer renderCount)
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.pageId
- pageClass
- pageParameters
- renderCount
- optional argumentpublic PageProvider(Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)
getPageInstance()
this provider
will return new instance of page with specified class.pageClass
- pageParameters
- public PageProvider(Class<? extends IRequestablePage> pageClass)
getPageInstance()
this provider
will return new instance of page with specified class.pageClass
- public PageProvider(IRequestablePage page)
getPageInstance()
this provider
will return the given page instance.page
- public IRequestablePage getPageInstance() throws PageExpiredException
IPageProvider
getPageInstance
in interface IPageProvider
PageExpiredException
- if the specified page
could not have been found and the constructor used did not provide enough information
to create new page instancepublic org.apache.wicket.request.mapper.parameter.PageParameters getPageParameters() throws PageExpiredException
IPageProvider
PageParameters
of the page.getPageParameters
in interface IPageProvider
PageExpiredException
- if the specified page
could not have been found and the constructor used did not provide enough information
to create new page instancepublic boolean isNewPageInstance()
hasPageInstance()
negation insteadisNewPageInstance
in interface IPageProvider
hasPageInstance()
public final boolean hasPageInstance()
getPageInstance()
this provider will return an existing instance and no
page will be created.hasPageInstance
in interface IPageProvider
public final boolean doesProvideNewPage()
doesProvideNewPage
in interface IPageProvider
true
iff the page instance held by this provider was instantiated by the
providerpublic boolean wasExpired()
IPageProvider
wasExpired
in interface IPageProvider
true>
if the page was created after its original instance expired.public Class<? extends IRequestablePage> getPageClass() throws PageExpiredException
IPageProvider
getPageClass
in interface IPageProvider
PageExpiredException
- if the specified page
could not have been found and the constructor used did not provide enough information
to create new page instanceprotected IPageSource getPageSource()
public void detach()
PageProvider(IRequestablePage)
constructor has been used or
getPageInstance()
has been called).detach
in interface IPageProvider
public void setPageSource(IPageSource pageSource)
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.pageSource
- protected void setPageParameters(org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)
pageParameters
- public Integer getPageId()
IPageProvider
getPageId
in interface IPageProvider
public Integer getRenderCount()
IPageProvider
getRenderCount
in interface IPageProvider
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.