public abstract class Page extends MarkupContainer implements IRequestablePage, IQueueRegion
MarkupContainer subclass, a Page can contain a
component hierarchy and markup in some markup language such as HTML. Users of the framework
should not attempt to subclass Page directly. Instead they should subclass a subclass of Page
that is appropriate to the markup type they are using, such as WebPage (for HTML markup).
Page has the following differences to Components main concepts:
Session and
increment for each new page. This numerical identifier is used as the component identifier
accessible via getId().IPageManager. PageParameters argument (which wraps any
query string parameters for a request). In case the page has both constructors, the constructor
with PageParameters will be used.Component.setVersioned(boolean). By default all pages are versioned if not configured differently
in PageSettings.setVersionPagesByDefault(boolean)WebPage,
MarkupContainer,
CompoundPropertyModel,
Component,
Serialized FormENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING| Modifier | Constructor and Description |
|---|---|
protected |
Page()
Constructor.
|
protected |
Page(IModel<?> model)
Constructor.
|
protected |
Page(org.apache.wicket.request.mapper.parameter.PageParameters parameters)
The
PageParameters parameter will be stored in this page and then those parameters
will be used to create stateless links to this bookmarkable page. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
componentChanged(Component component,
MarkupContainer parent)
This method will be called for all components that are changed on the page So also auto
components or components that are not versioned.
|
void |
componentRendered(Component component)
Adds a component to the set of rendered components.
|
void |
detachModels()
Detaches any attached models referenced by this page.
|
void |
dirty() |
void |
dirty(boolean isInitialization)
Mark this page as modified in the session.
|
int |
getAutoIndex()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
String |
getId()
Gets the id of this component.
|
MarkupType |
getMarkupType()
Get the type of associated markup for this component.
|
Class<? extends Page> |
getPageClass() |
int |
getPageId() |
org.apache.wicket.request.mapper.parameter.PageParameters |
getPageParameters()
The
PageParameters object that was used to construct this page. |
PageReference |
getPageReference()
Gets page instance's unique identifier
|
int |
getRenderCount()
Returns the number of times this page has been rendered.
|
long |
getSizeInBytes() |
boolean |
getStatelessHint()
Returns whether the page should try to be stateless.
|
String |
hierarchyAsString() |
protected void |
internalOnModelChanged()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
boolean |
isBookmarkable()
Bookmarkable page can be instantiated using a bookmarkable URL.
|
boolean |
isErrorPage()
Override this method and return true if your page is used to display Wicket errors.
|
boolean |
isPageStateless()
Gets whether the page is stateless.
|
protected void |
onAfterRender()
Called immediately after a component and all its children have been rendered,
regardless of any exception.
|
protected void |
onBeforeRender()
Called on all visible components before any component is rendered.
|
protected void |
onConfigure()
Called on all components before any component is rendered.
|
protected void |
onDetach()
Called to allow a component to detach resources after use.
|
protected void |
onInitialize()
This method is meant to be used as an alternative to initialize components.
|
protected void |
onRender()
Implementation that renders this component.
|
void |
renderPage()
Renders the page
|
boolean |
setFreezePageId(boolean freeze)
Sets whether or not the page is allowed to change its page id.
|
void |
setNumericId(int id)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
Page |
setStatelessHint(boolean value)
Sets whether the page should try to be stateless.
|
void |
setWasCreatedBookmarkable(boolean wasCreatedBookmarkable)
THIS METHOD IS NOT PART OF WICKET API.
|
String |
toString()
Get the string representation of this container.
|
boolean |
wasCreatedBookmarkable()
Checks if this page was created using one of its bookmarkable constructors
|
boolean |
wasRendered(Component component)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
|
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, visitChildren, visitChildrenadd, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onComponentTag, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanCallListenerAfterExpiry, detach, get, getBehaviorById, getBehaviorId, getPage, getPageRelativePathdetachdequeue, getRegionMarkup, newDequeueContextforEach, spliteratorprotected Page()
protected Page(IModel<?> model)
model - See ComponentComponent.Component(String, IModel)protected Page(org.apache.wicket.request.mapper.parameter.PageParameters parameters)
PageParameters parameter will be stored in this page and then those parameters
will be used to create stateless links to this bookmarkable page.parameters - externally passed parametersPageParameterspublic org.apache.wicket.request.mapper.parameter.PageParameters getPageParameters()
PageParameters object that was used to construct this page. This will be used in
creating stateless/bookmarkable links to this pagegetPageParameters in interface IRequestablePagePageParameters The construction page parameterpublic final void componentRendered(Component component)
component - The component that was renderedpublic void detachModels()
detachModels in class Componentprotected void onConfigure()
Component
Overrides must call super.onConfigure(), usually before any other code
NOTE: Component hierarchy should not be modified inside this method, instead it should be
done in Component.onBeforeRender()
NOTE: Why this method is preferrable to directly overriding Component.isVisible() and
Component.isEnabled()? Because those methods are called multiple times even for processing of
a single request. If they contain expensive logic they can slow down the response time of the
entire page. Further, overriding those methods directly on form components may lead to
inconsistent or unexpected state depending on when those methods are called in the form
processing workflow. It is a better practice to push changes to state rather than pull.
NOTE: If component's visibility or another property depends on another component you may call
other.configure() followed by other.isVisible() as mentioned in
Component.configure() javadoc.
NOTE: Why should Component.onBeforeRender() not be used for this? Because if a component's
visibility is controlled inside Component.onBeforeRender(), once invisible the component will
never become visible again.
onConfigure in class Componentpublic final void dirty()
dirty(boolean)public boolean setFreezePageId(boolean freeze)
setFreezePageId in interface IManageablePagepublic void dirty(boolean isInitialization)
page storeisInitialization - a flag whether this is a page instantiationprotected void onInitialize()
ComponentPage thus providing the component with an atomic callback
when the component's environment is built out.
Overrides must call super#Component.onInitialize(). Usually this should be the first thing an
override does, much like a constructor.
Parent containers are guaranteed to be initialized before their children
It is safe to use Component.getPage() in this method
NOTE:The timing of this call is not precise, the contract is that it is called sometime
before Component.onBeforeRender().
onInitialize in class MarkupContainerpublic final int getAutoIndex()
public final String getId()
ComponentgetId in interface IRequestableComponentgetId in class Componentpublic final long getSizeInBytes()
getSizeInBytes in class Componentpublic final boolean getStatelessHint()
getStatelessHint in class ComponentComponent.getStatelessHint()public final String hierarchyAsString()
public boolean isBookmarkable()
isBookmarkable in interface IRequestablePagepublic boolean isErrorPage()
public final boolean isPageStateless()
isPageStateless in interface IManageablePagepublic final void setNumericId(int id)
id - The idpublic final Page setStatelessHint(boolean value)
value - whether the page should try to be statelesspublic String toString()
toString in class MarkupContainerprotected void componentChanged(Component component, MarkupContainer parent)
component - parent - protected final void internalOnModelChanged()
internalOnModelChanged in class ComponentComponent.internalOnModelChanged()protected void onBeforeRender()
Component
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading Component.onBeforeRender() call to its
children it is strongly recommended that super call is made at the end of the override.
onBeforeRender in class ComponentMarkupContainer.addOrReplace(Component...)protected void onAfterRender()
ComponentonAfterRender in class Componentprotected void onDetach()
ComponentonDetach in class MarkupContainerprotected void onRender()
ComponentonRender in class MarkupContainerpublic MarkupType getMarkupType()
MarkupContainergetMarkupType in class MarkupContainerpublic PageReference getPageReference()
public int getPageId()
getPageId in interface IManageablePagepublic int getRenderCount()
IRequestablePageFor example a same page might have been rendered in two separate tabs. Page render doesn't change page id but it can modify component hierarchy. Request listeners on such page should only work in tab where the page was rendered most recently.
getRenderCount in interface IRequestablePagepublic final void setWasCreatedBookmarkable(boolean wasCreatedBookmarkable)
wasCreatedBookmarkable - public final boolean wasCreatedBookmarkable()
wasCreatedBookmarkable in interface IRequestablePagetrue if this page has been created by a bookmarkable URL,
false otherwise.IRequestablePage.wasCreatedBookmarkable()public void renderPage()
IRequestablePagerenderPage in interface IRequestablePagepublic final boolean wasRendered(Component component)
component - Copyright © 2006–2018 Apache Software Foundation. All rights reserved.